Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 16: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, 09:39
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Posts: 1,646
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
Data Warehousing on System z
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 02-23-08, 00: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, 23: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, 05:48
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Posts: 1,646
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
Data Warehousing on System z
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

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