If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > cron job scheduling

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-25-06, 12:49
chinatrain99 chinatrain99 is offline
Registered User
 
Join Date: Sep 2003
Posts: 73
cron job scheduling

I want to kick off a db2 reorg every 4th Sunday at 3:00 a.m. What would the crontab command look like??
Reply With Quote
  #2 (permalink)  
Old 08-25-06, 14:44
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Put the following line in your cron file:
0 3 22-28 * sun db2 reorg ....
(since the 4th sunday of a month is always between the 22nd and the 28th).
Or better, put the "db2 reorg" command in a script and give the script name as the command.

Beware that some crond implementations will OR the day-of-month and day-of-week fields, i.e., the above will run on every sunday AND on every 22nd etc of the month.

In this case it's safer to move some of the logic into the script:
have a cron entry of the form
0 3 22-28 * * exec $HOME/script.sh
and start the script with:
test `date +%u` = 7 || exit 0
or somewhat safer:
test `date +%a` = 'Sun' || exit 0

If you crond does not understand the range 22-28 notation, replace it by 22,23,24,25,26,27,28
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/

Last edited by Peter.Vanroose; 08-25-06 at 14:47.
Reply With Quote
  #3 (permalink)  
Old 08-25-06, 15:13
chinatrain99 chinatrain99 is offline
Registered User
 
Join Date: Sep 2003
Posts: 73
Thanks Peter...I'll try it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On