2

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?

3

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.

3
  • I appreciate the tool you've created, but this isn't worth $50 to me to solve. If I had more complex requirements that your tool addresses, then it might be a different story... but for my needs it's overkill. I just reboot the server manually from time to time as needed. It's less convenient but only a little. – JVC Oct 5 '16 at 1:00
  • Good to hear you have a workable solution. – Graham Miln Oct 5 '16 at 5:07
  • well... it's really no solution since I'm still in the exact same boat I was when I posed the original question. I still wish I had an automated (and free) way to reboot the server each night but since I don't, I'm just accepting that I can't do it. – JVC Oct 5 '16 at 14:15
0

Well, you could use cron to submit a sudo shutdown -r now command, but it's hardly elegant. I am in the same position, with users with mapped drives stopping the server rebooting.

2
  • Could you expand your answer to detail how someone would set this up? – grg Oct 18 '16 at 18:49
  • I agree, an expended answer on how to do this would be potentially useful to some reading this question, though personally I'd prefer a more elegant solution like yourself. – JVC Oct 18 '16 at 23:55
0

The command syntax was provided in the previous answer, but was not quoted. Here it is:

sudo shutdown -r now

Here's a recommended way to execute it periodically: Schedule a task in MacOS

Keep in mind: sudo requires authority, and authenticating within a script is generally unsafe.

Do this instead: Using sudo in a batch script

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .