Skip to main content
Question

Force a reboot at a specific time

  • August 27, 2019
  • 2 replies
  • 15 views

Forum|alt.badge.img+8

Could someone recommend the best way to force a reboot at a specific time even if there is someone logged in? I want my lab iMacs to reboot at 2am every morning and I have a scheduled task for it but if a user was logged in with a program open that requires a save then it does not reboot. There is probably a very simple setup for this but it eludes me at the moment. Any assistance would be appreciated!

2 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • August 27, 2019

You could start by looking at the man page for pmset. Actions can be scheduled, but I'm not sure if 'restart' is one of the options. I know shutdown and startup can be scheduled with it.

If that doesn't get you what you need, another option would be to craft and deploy a custom LaunchDaemon that uses a StartCalendarDate that just calls a forced restart at the time you want, i.e. at 2 am.


Forum|alt.badge.img+16
  • Valued Contributor
  • August 28, 2019

I think our solution was to use pmset to wake or poweron at around 2am (I also randomised it over the span of an hour to spread the load), then a seperate once per day policy to restart the device time limited to acceptable hours and covering the wake time. It didn't restart every single device every single night, but it did it relaibly enough to avoid most of the common issues. The other aspect of doing it this way is the restart can be done in such a way as to allow any opther policies that might kick off as a result of the wake to complete beforehand.