在00h和13:30每天执行crontab两次 [英] execute crontab twice daily at 00h and 13:30

查看:691
本文介绍了在00h和13:30每天执行crontab两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在每天的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两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆