Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crontab question

Status
Not open for further replies.

kukuluku

MIS
May 2, 2002
56
US
I thought the following line in the crontab would run only on 3rd Sunday. It turns out to be running Sunday plus every day from 15-22. I am using HP. Is this only for HP or is this generic for all Unix. How would you run a job on 3rd Sunday only?

30 02 15-22 * 0 /oracle/local/bin/rebuildndx.ksh fsprod

Thanks in advance.
 
Unfortunately, I don't think there is a way to handle the third Sunday of the month issue directly from cron, unless you run a script every Sunday from cron that tests to see if it is the third Sunday or not.

The file crontab fields are:
Minutes
Hours
Days/Month
Months
Days/Week

in that order. Looking at your statement, I assume the job is running at 2:30 AM every Sunday falling on days 15 thru 22 of each month.

You may wish to try:

30 02 * * 0
with a script that tests to see if it is the thrid Sunday or not.

Good Luck!!!!!
 
If the job 'is running at 2:30 AM every Sunday falling on days 15 thru 22' as you said, then it should just run once a month.

Very interestingly, we found that the job runs on 15, 16, 17 & 18.

By reading man page from HP, it says:
two fields: monthday and weekday, If both are specified in an entry, they are cumulative. For example,

0 0 1,15 * 1 command

runs command at midnight on the first and fifteenth of each month, as well as every Monday.


However, from Sun's page (support), I found:

30 1 * 2,4,6,8,10,12 3-5 usr/bin/wall /var/tmp/message
At 1:30 on Wednesday through Friday of every other month send
a message to everyone on the system, using the wall command.

If the cumulative only for monthday and weekday only? If others should be cumulative as well, then this should be from Wednesday through Friday and every date of every other month.

Can anyone clarify this?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top