Link to home
Start Free TrialLog in
Avatar of Dave_Watkin
Dave_Watkin

asked on

Scheduled Restart in OSX

OK - simple enough I hope, although I'm struggling....

We have a bug in the server software on one of our UNIX servers. This isn't important as we have a simple workaround until they fix it. All we have to do is remember to restart our OSX G5 clients every 24 hours. BUT since not doing this can result in significant data loss I want a foolproof solution that restarts them automatically. I thought about putting a Cron command in, but it doesn't seem to handle the restart command. There must be a simple program or utility or something that will do this...

I found one utility called Kudown - but it only works with 10.1 and 10.2 - I'm on 10.3.5
ASKER CERTIFIED SOLUTION
Avatar of brettmjohnson
brettmjohnson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dave_Watkin
Dave_Watkin

ASKER

Maybe I did it incorrectly, but once I restarted it didn't want to do it again.

Can you run me through the whole thing?
I'll make it a 150 pointer!
To make it automatically run daily,

create a text file in /etc/cron.daily with the command from brett, for example called dailyrestart

#! /bin/bash
shutdown -r +15  "System will reboot at 1:15 - save your work NOW!"

and make sure that this line is in your /etc/crontab

02 4 * * * root run-parts /etc/cron.daily

It should run the command dailyrestart every day now.

Good luck.




Couple of things to clarify please:-

I have the file crontab and I have a file called daily but I don't have cron.daily.

1. Do I create one called cron.daily
2. Is the command for the text file crontab Bretts ie 0 1 * * * (I see this as 1am daily) or 02 4 * * * (is this 4:02 daily)

Also, since you have both been helpful, how do I split points!
Dave,

I think I have to made a correction.  Brett's command is perfect. It should run @ 1am every day.

My way (cron.daily) is a 'cron management', so you don't have 100 cron that you run daily in crontab, but all those task will be in cron.daily.

1. the 'daily' is that a directory or a file?  As far as I'm concern, my cron.daily is a directory containing all the task I wanted to do on daily basis.  If yours is call 'daily', then put the 'dailyrestart' inside it.  It doesn't matter what name does it use, just don't forget to change the correspondent directory in crontab.

2. Yes, sorry the timing is up to you. :)  It should be 0 1 * * * if you want to run it @ 1am

Again, Brett's way should work perfectly.  Check your cron log for any error of why it didn't do it after you restart.
Actually the "daily" is a file.

I'll just create a directory called cron.daily and see what happens!

Thanks
Another addition :

1. I found it in my unsorted download folder : http://h5197.serverkompetenz.net/cronnix/  It's suppose to be a gui front end for cron.

2. Points.  Give it to Brett.  His suggestion is correct.

Thanks to both of you for your help. Brett, you get the points

 - idarmadi - generous to excess!