or Connect
AppleInsider › Forums › General › Genius Bar › Unix crontab for forced shutdown
New Posts  All Forums:Forum Nav:

Unix crontab for forced shutdown

post #1 of 4
Thread Starter 
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
post #2 of 4
Thread Starter 
Quote:
Originally Posted by Neruda View Post

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
post #3 of 4
Why do you want to use "now"? You should give users some time to log off and save their work. 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"

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.
Most of us employ the Internet not to seek the best information, but rather to select information that confirms our prejudices. - Nicholas D. Kristof
Reply
Most of us employ the Internet not to seek the best information, but rather to select information that confirms our prejudices. - Nicholas D. Kristof
Reply
post #4 of 4
Thread Starter 
Quote:
Originally Posted by talksense101 View Post

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.

Quote:
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.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Genius Bar
AppleInsider › Forums › General › Genius Bar › Unix crontab for forced shutdown