如何在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的回答,只是把它们放在一起以防对任何人有用。还有,感谢小叮当。
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/