[CentOS] setup schedule cron job every other week?
jdmls at yahoo.com
Wed Jan 6 15:49:26 UTC 2010
From: Brent L. Bates <blbates at vigyan.com>
> From: mcclnx mcc
> > 0 0 8-31/14 * 6 /script.sh
> From: John Doe
> > 0 0 8-14 * 6 /script.sh
> > 0 0 22-28 * 6 /script.sh
> According to the man page, neither of these will not do what the OP
> wants. Both will execute the command EVERY Saturday. The first will also
> execute it on the 8th and 22nd of the month. The second will execute the
> command TWICE a day AND days 8-14 AND 22-28. The man pages says if any of the
> day parameters match, the command is executed. Unfortunately for the OP, the
> day parameters are an OR operation and not an AND operation.
Oops, I missed that part... you are right.
Guess the date check will have to be out of cron...
In case the even/odd week of the year does not work (I am not sure all months will start on odd weeks; do they?), here's another try:
0 0 * * 6 [ $((`date +"%d"`%14)) -ge 8 ] && script.sh
Would that work?
More information about the CentOS