linux - crontab 在移动、复制、解压缩、移动之间添加等待时间
问题描述
如何在 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 #then 在编辑器中输入代码 #Note $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/
推荐阅读
- javascript - 如何为 React 中现有的 Fetch API 调用添加数据的条件代码?
- python - 使 Matplolib 图不连续,其中 Y 值为 0
- laravel - 对于 1gb 或更大的文件,Laravel 存储 put() 或 putFileAs() 到 S3 目录失败
- junit - when().thenReturn() 不返回服务层方法调用
- c# - Visual Studio 中的白色文件夹是什么意思?
- python - 在 VSCode 中,Python 调试器每次调试时都会启动一个新终端
- javascript - 将对象形状的数组转换为不同的数组块
- php - MPDF pdf 未在任何浏览器中打开,Codeignitor 中未显示错误
- python - 匹配数字按顺序列出python
- javascript - 从javascript中的url路径中提取参数