Unix crontab for forced shutdown
I tried making a crontab as root to have all of the computers in our labs shutdown at 4:30 everyday.
I first tried doing this through the command line as root, but the shutdown -h now command is not being executed for some reason. I tried doing this with Cronix with the same result.
I did an osascript cron (tell application system events shutdown) and that works, but the problem is that the computer provides a prompt if there is any open application or unsaved document so the computer will not shutdown.
Both of the following do not work. Any ideas? I could not GTFA.
30 16 * * * sudo -u root shutdown -h now
30 16 * * * shutdown -h now
Thanks
I first tried doing this through the command line as root, but the shutdown -h now command is not being executed for some reason. I tried doing this with Cronix with the same result.
I did an osascript cron (tell application system events shutdown) and that works, but the problem is that the computer provides a prompt if there is any open application or unsaved document so the computer will not shutdown.
Both of the following do not work. Any ideas? I could not GTFA.
30 16 * * * sudo -u root shutdown -h now
30 16 * * * shutdown -h now
Thanks
Comments
Both of the following do not work. Any ideas? I could not GTFA.
30 16 * * * sudo -u root shutdown -h now
30 16 * * * shutdown -h now
Got it.
30 16 * * * /sbin/shutdown -h now
28 16 * * * /sbin/shutdown -h "16:30"
If you want to do it the OS X way, you can set the shutdown and start up schedule under Energy Saver. But that will give you the prompts.
Why do you want to use "now"? You should give users some time to log off and save their work.
The computers are in an open area and I turn them off before I leave everyday. The problem is that kids often turn the computers on after I leave. The energy saver shutdown option does not work because more often than not people leave open applications/documents which cause prompts that stop the shut down. If this happens on a Friday the computers are on all weekend and the same happens over vacations.
Set the cron job a couple of minutes earlier and set the shutdown at 4:30, it will provide the warnings to anyone using a terminal session.
28 16 * * * /sbin/shutdown -h "16:30"
This looks like a better solution. I also had a cron to open a file text file at 4 and 4:15 warning users that the computers will shut down at 4:30. I'll try this instead.
Thanks for the reply and the tip.