crontab 在移动、复制、解压缩、移动之间添加等待时间

crontab add a wait time between move, copy, unzip, move

如何在 crontab 作业命令之间添加等待时间?

此代码中可能还有其他错误。但主要目标是在晚上 10 点执行一行,等待上一行完成,然后移动到下一行,等等...

crontab -e

#* 22 * * * ##At 10pm, do the following in order waiting for each to complete before moving on.


mv /home/$USER/isengard /home/$USER/middleearth/mirkwood
wait
cp -r -p /home/$USER/middleearth/mirkwood /home/$USER/middleearth/shire/
wait
mv /home/$USER/middleearth/mirkwood /home/$USER/middleearth/rohan/
wait
gunzip -r /home/$USER/middleearth/rohan/
wait
mv /home/$USER/middleearth/rohan /home/$USER/middleearth/gondor/

感谢 Nate Eldredge 的回答,将所有内容放在一起以防对任何人有用。另外,感谢 Tink。

crontab -e #然后在编辑器中输入代码#注意$USER可能需要改成你的名字。

* 22 * * * mkdir -p /home/$USER/me/arnor/hobbits/ ; cp -r -p /home/$USER/me/arnor/hobbits/ /home/$USER/me/shire/ ; mv /home/$USER/me/arnor/hobbits/ /home/$USER/me/buckland/ ; gunzip -r /home/$USER/me/buckland/hobbits ; mv /home/$USER/me/buckland/hobbits /home/$USER/me/gondor/