我想使用以下模式从上午 6:30 立即开始每 1 分钟无限期地执行 cron 作业:
30/1 6 * * *
但是 cron 在早上 6:59 停止,此后不再执行。
我应该将模式设置为30/1 6-0 * * *
吗?但恐怕在上午 12 点第一次出现后,cron 可能不会被调用。
那么,以下模式可以解决该问题吗?
30/1 6-* * * *
最佳答案
每 1 分钟运行一次 cron。对于如此频繁的 cron 作业,应该仔细弄清楚竞争条件。
$ cat ./my1min-cron
*/1 * * * * root /path/to/some/script &> /path/to/some/log
$ chmod 644 ./my1min-cron
使用 at
将其放置在下一个上午 6:30。例如,
# Create a script that will copy the cron file to /etc/cron.d/
$ cat ./putcronscript.sh
cp -vf ./my1min-cron /etc/cron.d/my1min-cron &> ./copycronscript.log
# Use at to put the cron script in place at 6:30 AM Tuesday. This is onetime operation.
$ at -f ./putcronscript.sh 6:30 AM Tue
# or
$ at -f ./putcronscript.sh 6:30 AM tomorrow
关于linux - 如何从特定时间开始无限地每 1 小时执行一次 cron 作业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48378609/