Is it possible to make crontab run after one's execution. I read that cron jobs start from top, but run parallel, doesn't wait one to finish. Is there any way that I can do like this? For example, let's say I have 3 cron jobs.
*/5 * * * * job1
*/5 * * * * job2
*/5 * * * * job3
I want job2 to run after job1 has completed, and job3 after job2 completed.
答案 0 :(得分:1)
You can have more than one command in a single crontab entry:
*/5 * * * * job1 ; job2 ; job3
答案 1 :(得分:0)
如果您想使用 /etc 中的全局 crontab,那就更简单了。 主要的 crontab 文件是 /etc/crontab。它包含这种类型的指令:
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
所以 Linux 使用 run-parts; run-parts 按字母顺序启动命令,所以只需在脚本中添加数字,如下所示:
等等...请避免使用点或其他对运行部分不合法的字符: