I would like to schedule a weekly restart at a certain time.

JiggyWalker
New Contributor II

Specifically, I would like a machine to restart (regardless of who is connected) every Friday at 6:00 PM. Can anyone help me with this?

2 ACCEPTED SOLUTIONS

flyboy
Contributor

I do something similar to this to restart some electronic signs each night.

The script below will set the computer to restart every Friday at 6:00pm

#!/bin/bash
pmset repeat restart F 18:00:00

pmset -g sched will show you any presently set power schedules

pmset repeat cancel will cancel the repeating restart/shutdown/wake, etc.

View solution in original post

JiggyWalker
New Contributor II

I take that back, I've set it up and will check out the results. Thanks!

View solution in original post

8 REPLIES 8

mm2270
Legendary Contributor III

A LaunchDaemon using a CalendarStartInterval for every Friday at 6 PM that just calls a /sbin/shutdown -r now command would do it.

JiggyWalker
New Contributor II

Pardon my ignorance but, I'm not familiar on how to do that.

flyboy
Contributor

I do something similar to this to restart some electronic signs each night.

The script below will set the computer to restart every Friday at 6:00pm

#!/bin/bash
pmset repeat restart F 18:00:00

pmset -g sched will show you any presently set power schedules

pmset repeat cancel will cancel the repeating restart/shutdown/wake, etc.

mm2270
Legendary Contributor III

Yep, forgot about pmset. Good thought @Berrier! Probably easier than with a LaunchDaemon.

JiggyWalker
New Contributor II

I take that back, I've set it up and will check out the results. Thanks!

sdagley
Esteemed Contributor II

I haven't had occasion to use it since 10.6, but

pmset repeat restart

did not force a restart, so a logged in user with modified documents would result in the Mac not restarting. You're better off with the

shutdown -r now

approach if that will be a problem.

danny_hanes
Contributor

Is there anyway to disable the "Cancel" button that pops up for the user? I have no issue with them seeing a countdown and being able to click the "Restart" button, but I would prefer they don't cancel it.

Also, is there a way to set a time at which the pop-up shows up? If I want it to show up 1hr before the restart or 4hrs before a restart, is that possible?

B-35405
Contributor

I've done this via Sys Pre, Energy Saver, Schedule. Made the changes on a VM while using the vm/computer to make a settings pkg with composer. Then pushed the pkg out to the computers that needed the settings updated. You'll have a few ways to do this.