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 ).
Does ayone has ideal how to do it?
Thanks.
___________________________________________________ 您的生活即時通 - 溝通、娛樂、生活、工作一次搞定! http://messenger.yahoo.com.tw/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 06/01/2010 00:47, 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 ).
Does ayone has ideal how to do it?
Maybe like that... 1 1 * * 6/2 /bla/bin/doit would read: do /bla/bin/doit at 1:01 every second saturday. Unverified, but see
#$ man 5 crontab
- -- best regards, markus
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 06/01/2010 00:47, 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 ).
Does ayone has ideal how to do it?
Maybe like that... 1 1 * * 6/2 /bla/bin/doit would read: do /bla/bin/doit at 1:01 every second saturday. Unverified, but see
#$ man 5 crontab
- -- best regards, markus
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 06/01/2010 00:47, 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 ).
Does ayone has ideal how to do it?
Maybe like that... 1 1 * * 6/2 /bla/bin/doit would read: do /bla/bin/doit at 1:01 every second saturday. Unverified, but see
#$ man 5 crontab
- -- best regards, markus
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
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@hogranch.com 寫道:
寄件者: John R Pierce pierce@hogranch.com 主旨: Re: [CentOS] setup schedule cron job every other week? 收件者: "CentOS mailing list" centos@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@centos.org http://lists.centos.org/mailman/listinfo/centos
___________________________________________________ 您的生活即時通 - 溝通、娛樂、生活、工作一次搞定! http://messenger.yahoo.com.tw/
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)?
Please read the cron man page. *THOROUGHLY*
A job running from cron DOES NOT HAVE YOUR ENVIRONMENT.
Does your script have #!/bin/bash at the top? If not, it will be run as Bourne shell, which has a lot of *nothing* of the features you expect to program with.
Check the environment that you require.
mark
From: mcclnx mcc mcclnx@yahoo.com.tw
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 `''
It says you miss a closing back-quote...
JD
From: mcclnx mcc mcclnx@yahoo.com.tw
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 ).
Not tested, might work... maybe: 0 0 8-31/14 * 6 /script.sh 8-31/14 should skip the first week and then go every 2 weeks (unless the /14 takes 1 for base instead of the 8)...
JD
From: John Doe jdmls@yahoo.com
From: mcclnx mcc
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 ).
Not tested, might work... maybe: 0 0 8-31/14 * 6 /script.sh 8-31/14 should skip the first week and then go every 2 weeks (unless the /14 takes 1 for base instead of the 8)...
Or, just use 2 entries: 0 0 8-14 * 6 /script.sh 0 0 22-28 * 6 /script.sh
JD