为什么在创建 tar.gz 文件后休眠

Why sleep after creating a tar.gz file

我正在审查 linux bash 脚本,这些脚本旨在每小时备份一个目录并将该备份复制到另一台服务器。这些脚本是 运行 by cron。它们都遵循相同的通用代码路径,如下所示:

cd /path/to/parent/directory
tar -zcvf data_backup.tar.gz data
sleep 10
# scp file to server

我想知道 sleep 10 命令的原因是什么。我知道这会导致进程停止 10 秒,但为什么作者会把它放在首位?我假设在 tar 命令完成后,文件将正确刷新到磁盘并且 scp 命令可以无错误地执行。

这些脚本 运行CentOS 6 和 CentOS 7 系统上可用。写剧本的人已经离开组织,联系不上

I would assume that after the tar command completed, then the file would be properly flushed to disk and the scp command could execute without errors

你的假设是正确的,我希望 sleep 命令是多余的。