Cronjob every two weeks

2019-08-14 17:57发布

问题:

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.



标签: shell cron