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

Monthly reboot script

Status
Not open for further replies.
Jul 10, 2007
6
US
Hi

Does anyone have any idea on how to set up crontab to run the reboot command on the first monday of every month. OR any script that can be put in cron.

Thanks
 
Are you sure you are askng the right question here?
Why do you think you need to reboot once a month?
If you think you need to reboot for some reason, what it that reason?
Why not reboot only when you apply fixes or do maintenance?
If, for instance, you find the system starts slowing down after a few weeks why not fix the problem rather than rebooting.
 
Firstly I'd agree with DukeSSD, you ought to be looking at why you need to reboot rather than how to do it but, if the following script run every Monday will do what you want
Code:
#!/bin/ksh
[[ $(date +%d) -le 7 ]] && shutdown -Fr #date +%d returns day of the month
The crontab entry should looklike (This example runs at 4am)
Code:
0 4 * * 1 /usr/local/bin/reboot.ksh

Ceci n'est pas une signature
Columb Healy
 
Thanks columb.Appreciate the script.

Dukessd I totally understand what you are talking about. But its the vendors policy to have a monthly backup and reboot. So just going along with their policy.

Thanks
 
!! It's the vendors policy? Since when did vendors make policy? Oh yes when there code has memory leaks and it saves them from fixing it..... ;-)



Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top