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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crontab question 1

Status
Not open for further replies.

444888

Technical User
Feb 3, 2004
4
0
0
US
Crontab question: I am new to unix and need to kickoff a reboot on a server on the first sunday of the month. So, my initial response was to use cron to do this for.
My cron was going to look like this: 30 0 1-7 * 0, so being new I presented this to several other unix folks whom told me that cron doesn't work that way...

My question is...How does cron handle the translation of the above? what's in between each statement add's or or's?

Does it interpret it as if it's 30 minutes after midnight and the date is 1 thru 7 and it's any month and it's Sunday?

OR, is there an Or somewhere in there?

The other unix folks explained to me that my cron tab would reboot the server on the 1st, 2nd, 3rd, 4th, 5th, 6th, and the 7th of the month as well as on Sunday.

Any clearity / help or documentation would be greatly appreciated.
 
What the other guys told you is correct. If you specify the day of the month and the day of the week, it does both, i.e. an "or" of the two. You'd have to add in some script logic to make it work that way.

Dennis
 
You can try this in your crontab:
30 0 * * 0 [ `date +%d` -le 7 ] && YourScriptName

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top