Cronjob every two weeks

自古美人都是妖i 提交于 2020-01-16 01:09:11

问题


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

This is what I've tried.

 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.

Thanks.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/34055122/cronjob-every-two-weeks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!