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 > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > biweekly schedule through cron

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-08, 15:46
anksagr anksagr is offline
Registered User
 
Join Date: Jul 2005
Posts: 102
biweekly schedule through cron

Hi All,

This is the first time I am posting on this forum.

I want to schedule my DB2 reorgchk every other sunday through cron.

I did the following:

PHP Code:
# Bi-Weekly REORGCHK for db2 databases.
00 06 1-7,15-21 * * [ "$\(date +\%a\)" == "Sun" ] && /usr/local/db2/online_reorgchk.sh 2>&
for some reason it runs just the first sunday that falls between 1-7 and does not run on the sunday that falls between 15-21.

Am I doing it right? Is there a better way to schedule a script every other sunday?

Thanks for the help

Anks
Reply With Quote
  #2 (permalink)  
Old 01-10-08, 08:39
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by anksagr
Code:
# Bi-Weekly REORGCHK for db2 databases.
00 06 1-7,15-21 * * ...
for some reason it runs just the first sunday that falls between 1-7 and does not run on the sunday that falls between 15-21.
This would run your command every day from the 1st thru 7th and 15th thru 21st of each month (at 6:00). So your statement saying that it just rons on the first Sunday is not true. The following should do the restriction for the Sunday as well:
Code:
00 06 1-7,15-21 * 7 ...
The crontab specifications for the weeks are fine. If it doesn't work, maybe your cron doesn't support this format? If so, you could split this up into multiple crontab entries.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 02-22-08, 23:58
Bob4480 Bob4480 is offline
Registered User
 
Join Date: Feb 2004
Location: Los Angeles, CA
Posts: 28
Try this

anksagr

Try this, it worked on my server.

Code:
00 06 1-7,15-21 * * test `date +\%a` = Sun && /usr/local/db2/online_reorgchk
Good Luck
Reply With Quote
  #4 (permalink)  
Old 03-07-08, 22:51
xtremenw xtremenw is offline
Registered User
 
Join Date: Mar 2008
Location: Tacoma, WA
Posts: 11
Quote:
Originally Posted by Bob4480
anksagr

Try this, it worked on my server.

Code:
00 06 1-7,15-21 * * test `date +\%a` = Sun && /usr/local/db2/online_reorgchk
Good Luck
Code:
00 06 1-7,15-21 * Sun /usr/local/db2/online_reorgch
Will do the same thing since the last * was for Day of Week. `man 5 crontab` gives the exact details...

Prevents the system from starting a shell command to check that it is sunday and continue if it is...
Reply With Quote
  #5 (permalink)  
Old 03-08-08, 04:48
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by Bob4480
anksagr

Try this, it worked on my server.

Code:
00 06 1-7,15-21 * * test `date +\%a` = Sun && /usr/local/db2/online_reorgchk
Good Luck
Why so complicated? Just use the infrastructure that cron provides.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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