我想在每天的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 ?
推荐答案为什么不放两个cron条目?一个是00:00,一个是13:30?我不认为你可以在一个条目中做你想要的,因为两分钟定义将适用于两个小时定义(如你所确定的)。
Why not put in two cron entries ? One for 00:00 and one for 13:30 ? I don't think you can do what you want in one entry, since the two minute definitions will apply for both hour definitions (as you've identified).
另一种方法是在00:00执行一个脚本。该脚本将执行原始脚本,然后等待13.5小时,然后再次执行该脚本。这很容易通过一个简单的sleep命令,但我认为这是不直观的,我不知道 cron 如何管理这样长时间运行进程(如果你编辑 crontab - 会杀死生成的作业等等)。
The 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.)
更多推荐
在00h和13:30每天执行crontab两次
发布评论