Re: setup schedule cron job every other week?

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



mcclnx mcc wrote:
> We have CENTOS 5 on DELL server.  I tried to setup schedule cron job to run every other week on Saturday (NOT first and third week ).
>   

lets see...

date +'%U'

returns the week number of the year, 00-51... and (( expression ))
evaluates arithmetic expressions, returning 'true' if they are non-zero.
weeknumber & 1 will be 0 for even weeks and 1 for odd weeks.

So... set up your cron job to run every Saturday, and in the beginning
of the job script, do something like...

(( $(date +'%V') & 1 )) && exit

which will exit if the week of the year is even. or, in the front of
your crontab line, something like....

30 1 * * 6 (($(date +'%V')&1)) && command-you-want-to-execute-on-even-weeks






_______________________________________________
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