每天 00 点和 13:30 执行两次 crontab [英] execute crontab twice daily at 00h and 13:30
问题描述
我想每天在 00:00 和 13:30 执行两次脚本,所以我写:
i want to execute a script twice daily at 00:00 and 13:30 so i write :
0,30 0,13 * * *
这对我来说似乎是错误的,因为像这样,脚本将在 00:00 、 00:30 、 13:00 和 13:30 触发.有什么想法吗?
it seems wrong for me, because like this, the script will fire at 00:00 , 00:30 , 13:00 and 13:30. Any idea ?
推荐答案
您不能在一个条目中做您想做的事,因为两分钟的定义将适用于两个小时的定义(正如您所确定的).
You can't do what you want in one entry, since the two minute definitions will apply for both hour definitions (as you've identified).
>
解决方案是(不幸的是)使用两个 cron 条目.一种用于 00:00,一种用于 13:30.
The solution is (unfortunately) use two cron entries. One for 00:00 and one for 13:30.
另一种选择是也许在 00:00 执行一个脚本.该脚本将执行您的原始脚本,然后等待 13.5 小时,然后再次执行该脚本.通过一个简单的 sleep 命令很容易做到,但我认为它不直观,而且我不确定 cron
如何管理如此长时间运行的进程(如果你编辑 crontab
- 它是否会杀死生成的作业等)
An alternative is perhaps to execute one script at 00:00. That script would execute your original script, then wait 13.5 hours and then execute that script again. It would be easy to do via a simple sleep command, but I think it's unintuitive, and I'm not sure how cron
manages such long running processes (what happens if you edit the crontab
- does it kill a spawned job etc.)
这篇关于每天 00 点和 13:30 执行两次 crontab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!