From: mcclnx mcc
0 0 8-31/14 * 6 /script.sh
From: John Doe jdmls@yahoo.com
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.
From: Brent L. Bates blbates@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?
JD
0 0 * * 6 [ $((`date +"%d"`%14)) -ge 8 ] && script.sh Would that work?
0 0 * * 6 [ $((`date +"%V"`&1)) ] && script.sh
would work better. except, uh oh.... what happens at the end/beginning of a year? its quite possible for the even numbered weeks in one year and the even weeks in the next year NOT to be every other week.
this is harder than it looks. I think you'll need to calculate total days since epoch date, modulo 14
[ $(( ($(date +"%s") / 86400) % 14)) -eq 9 ]
where %s is seconds since 1970-01-01 00:00:00 UTC, which was a Wednesday here (PST) at least.