I am looking for a CRON expression which should run every 2 weeks on Thursday. As an e.g. if I execute the JOB on June 24th Thursday , next execution should be on July 8th THU, next is JULY 22nd THU, AUGUST 5th and so on.
Asked
Active
Viewed 3,865 times
-1
-
Questions about operating systems, their utilities, networking and hardware, are off topic here. [What topics can I ask about here?](https://stackoverflow.com/help/on-topic). Please delete this and ask, instead, on https://unix.stackexchange.com/ – Rob Jun 25 '21 at 23:18
1 Answers
0
AFAIK, cron jobs don't like scheduling something every X days where X is greater than 7. You will need to cheat a bit by either scheduling something to happen on the first and third Thursday of a month, such as 0 0 1-7,15-21 * 3
as suggested by this answer over on ServerFault.
Alternatively, you can change the script of the job itself to only execute on odd-numbered weeks as suggested by other answers on that same post above. For example:
0 0 * * 4 [ `expr \`date +\%V\` \% 2` -eq 0 ] && echo "execute script"
This cron job will run every Thursday, but the script will only run the command after the &&
if the current week index is divisible by 2.

Abion47
- 22,211
- 4
- 65
- 88