Re: setup schedule cron job every other week?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



> 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.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux