How to restart on a schedule, if network users are connected

power-managementrestart

I want to schedule a nightly restart of my OSX media server, but I routinely have other machines in the house connected to this machine remotely (since it's also our TimeMachine system, iTunes library, etc.)

It's trivial to set a scheduled restart, but it always fails if other users are connected, which in my case they always are.

How can I schedule a nightly restart of this machine, that will automatically kick any connected users, quit all apps, and restart?

Also, what effect will this have on the formerly-connected applications like iTunes, TimeMachine, etc.? Will they simply see the machine again after restart and resume operations? Or will it cause them to get into a bad state?

Best Answer

You can use a third party tool like Power Manager to ensure the restart completes. The tool's web site includes has a recipe that shows how to schedule a restart.

DssW Power Manager for Mac OS X

Power Manager will ensure your Mac restarts, even if other processes or applications try and block the process:

Power Manager is multiple user savvy and first deals with the logged in users. The following steps happen within each logged in user’s session:

  • Running applications are sent a quit request.
  • Running applications are given time to quit.
  • If an application has not quit in time, the application is force quit.
  • With all the applications quit, the user is logged out.

Once all the users are logged out, Power Manager then asks Mac OS X to shut down. You can watch this sequence play out in the transcripts of the Mac’s system.log file.

With regard to formerly-connected applications like iTunes, and Time Machine; these applications will be quit and no data will be lost. Time Machine will resume backing up where it was stopped - it was designed to be interrupted.

After restarting, previously connected Macs will need to reconnect and be asked to resume playing any shared content. No harm will come to them.

If you are watching a streaming film while the media server restarts, the film will stop and you will probably need to resume the film playing. A smart player might seamlessly handle the dropped network connection but that is outside of the control of the media server.

Disclosure: I created Power Manager.