I have this problem in my office that multiple Macs always run 24/7 and my boss said that I need to make it stop. Now I don't have much experience with Macs, I'm more the Windows type.

I have one Mac who acts as a server and would like to run a script or something like that to orchestrate the power status of several computers if that helps.

How can I shut down all of those 7-8 Macs remotely at 11:30pm?

  • 6
    There is actually a setting in System Preferences to shutdown at a specific time. If this doesn't work for you (for whatever reason): Is the Mac acting as a server running "OSX Server"? Have you enabled password-less remote login via ssh?
    – nohillside
    Commented Nov 14, 2016 at 14:34
  • 1
    Why do they need to stop? Don't they go into sleep mode?
    – mmmmmm
    Commented Nov 14, 2016 at 14:35
  • This might be easier to control if a central Mac is upgraded to OS X Server. Commented Nov 15, 2016 at 9:02

3 Answers 3


As patrix has pointed out in a comment, you can set up any Mac to start up or wake up, and sleep or shut down at specific times, via the System Preferences -> Energy Saver -> Schedule... settings.

You could also try using AppleScript, e.g. this code (edit it with Script Editor, then save as an Application):

tell application id "com.apple.systemevents" -- System Events.app
    shut down
end tell

And then use OSX's Launch Services to run this script at a given time. To set this up, you could use a free tool such as "Lingon X".

Besides, why shut them down like this? If all you care about is to preserve electrical power, why not instead set up the Macs to go to Sleep after being idle for, say, 30 minutes? That way, they will go to sleep much sooner usually, saving more power. If they do not go to sleep as expected, you can check with the Terminal command pmset -g what might prevent them from sleeping. Often it's a pending print task (which you may want to delete, then) or mounted server volumes.

  • 2
    + for also including the more robust alternative that achieves the same effect and more.
    – Pysis
    Commented Nov 14, 2016 at 16:30
  • Internet Sharing could also Prevent the mac from sleeping
    – FrontENG
    Commented Nov 15, 2016 at 1:40

You can use pmset to do this and it will be a "once and done" solution.
Once you issue the pmset command, it will shutdown/startup/wake on the schedule you set; you won't have to create a script that runs at a predetermined time each time.

pmset uses this format:

pmset schedule day/date time

Here are a few examples:

  • pmset repeat sleep MTWRF 23:30:00 puts the Mac to sleep weekdays at 11:30pm

  • pmset repeat poweroff MTWRF 23:30:00 shuts down the Mac weekdays at 11:30pm

  • pmset schedule shutdown "12/31/2016 23:59:00" shuts down the computer at 11:59pm New Year's Eve.

  • pmset repeat wakeorpoweron MTWRF 06:30:00 wakes the Mac every weekday at 7:00am so that it's ready to go when the employee shows up.

You don't need to use a script to do this, all you need to do is remotely access each one of the Macs (all 7 or 8) of them and issue the command as an admin.

However, if you needed to run a script you could add this command to a simple bash script similar to the following:


# Array of Mac hostnames separated by spaces
my_macs=(mac1 mac2 mac3 mac4)

#Steps through each hostname and issues SSH command to that host

for n in my_macs
   ssh admin@$n "pmset repeat sleep MTWRF 23:30:00"

exit 0

Now, keep in mind that the script is for illustration purposes and technically outside the scope of this answer. I just wanted to illustrate how this could be done.

  • 2
    You should point out that that's the equivalent to using the System Preferences. Commented Nov 14, 2016 at 14:47

If you need to manage a bunch of Macs, I recommend using Apple Remote Desktop. It should let you push any number of standard settings to the Macs you need to manage for your job and let you avoid having to write and maintain a script.

On each machine you need to enable Remote Management in System Preferences.app > Sharing. After that, you can adjust anytime you need to.

You must log in to answer this question.

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