Saturday, August 18, 2012

cron job q

hello ! 
I want to run a daily job at 4:30 am on the 1st of each month, but also want it to run it at 1:45 am on every other day. how is this done in the crontab? (AIX v5.3) 


45 1 * 1 * /path/script 
30 4 * 2,3,4,5,6,7,8,9??. * /path/script 
-example of 1:45am 

45 01 * * 1 3 5 /job/name/.....

s


so basicly a crontab has 5 fields as follows: 
minute (0-59), 
hour (0-23), 
day of the month (1-31), 
month of the year (1-12), 
day of the week (0-6 with 0=Sunday).

  Rick, this record will try to run every Monday, 1:45 script with name 3 with parameters 5 and /job/name 

My mistake, should be 45 1 1 * * /path/script and 30 4 2,3,4,5,6,7,8,9.. * * /path/script 

No. Should be : 

30 4 1 * * /path/script 
45 1 2,4,6,8,10.12,... * * /path/script 
As I read should every other day, not every even day 
So should be 45 1 2,3,4,5,6.. * * /path/script 
'Every other day', at least where Im from, means to skip a day. So shouls be : 

45 1 2,4,6,8,10.12,...,32 * * /path/script 

or 

45 1 1,3,5,7,9.13,...,31 * * /path/script
Lets the author clarify what he/she want. I know, my English is not so good but for me the sentence 
.. on the 1st of each month, .. on every other day.. 
mean on 1 day do something on all other days in the month do other 

simple, two entries ... 

First one -------------> 30 4 1 * * /path_to_script ( here irrespective of month of the year and day of the week the script will run on 1st of every month exactly at 4 hours 30 minutes . 

second one ---------> 45 1 3,5,7,9,....31 * * /path_to_script 
or 
second one ---------> 45 1 2,4,6,8,....30 * * /path_to_script 
In second one, the person opened the forum in not clear. On each other , whether he want to start on day basis as i said earlier or we have to put the script on day of the week like 
45 1 * * 2,4,6 /path_to_script or even may be 45 1 * * 3,5,7 /path_to_script 

However is a very good tricky questions to screw our basics . . .

0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM