[CentOS] setup schedule cron job every other week?

mcclnx mcc mcclnx at yahoo.com.tw
Fri Jan 8 16:38:02 UTC 2010


Thank you.  This script only work on regular enviroment like sh, ksh and bash.  When I put on cron job I got error message:

/bin/sh: -c: line 0: unexpected EOF while looking for matching `''

any ideal (CENTOS 4 and 5)?



--- 10/1/5 (二),John R Pierce <pierce at hogranch.com> 寫道:

> 寄件者: John R Pierce <pierce at hogranch.com>
> 主旨: Re: [CentOS] setup schedule cron job every other week?
> 收件者: "CentOS mailing list" <centos at centos.org>
> 日期: 2010年1月5日,二,下午7:18
> 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 at centos.org
> http://lists.centos.org/mailman/listinfo/centos
> 

___________________________________________________ 
 您的生活即時通 - 溝通、娛樂、生活、工作一次搞定! 
 http://messenger.yahoo.com.tw/


More information about the CentOS mailing list