每两周一次Cronjob [英] Cronjob every two weeks

查看:219
本文介绍了每两周一次Cronjob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在星期日的午夜每两周进行一次cronjob。

I want to run a cronjob every two weeks on Sundays at midnight.

这是我尝试过的方法。

 0 0 * * 0/2 /path/to/script

这是正确的吗?
下一个星期日然后每两周执行一次吗?我目前无法在服务器上对其进行测试。.请帮助。

Is this correct? Will it execute the next Sunday and then every two weeks? I cant test it on my server at this point.. Please help.

谢谢。

推荐答案

AFAIK cron无法处理每隔第二周。

AFAIK cron can't handle "every second week".

相反,您可以在周日运行它午夜并修改脚本出口(如果不是您希望运行的星期日的话)。

Instead, you could run it every Sunday at midnight and modify the script exit early if it's not one of the Sundays you want it to run.

如果无法修改脚本,请创建一个包装脚本,仅在预定的星期日调用主脚本,然后从cron调用包装器。

If modification of the script is not possible, create a wrapper script that only calls the main script when it's a scheduled Sunday and call the wrapper from cron.

这篇关于每两周一次Cronjob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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