You don't need paid apps to do this as it's very simple using Bash (the default shell in Terminal).
You can have the computer shutdown by issuing the command in Terminal
$ sudo shutdown -h now
If you try it, it will shutdown your Mac immediately.
What each part does
sudo = run as the root user
shutdown = the command to shutdown the system
-h = halts the system
now = immediately
So, if you wanted to shut the computer down 5 minutes from now, your command would be:
$ sudo shutdown -h +5
You can even schedule it for a reboot (
-r instead of
-h) at a particular time (11:00pm every night)
$ sudo shutdown -r -h 23:00
While that command all by itself, would do what you want, it's limited because of
sudo; you'll need to enter your password when it's run. This means you'll have to be on-prem at each machine each time you want to issue the command (every day), so we need something that will run the command as
root so it will be automatic.
Writing a Bash Script
The script for this is quite simple; it's a single line that calls the shutdown command:
/sbin/shutdown -h now
auto_shutdown.sh and save it to a convenient location. Make it executable by issuing the command:
$ sudo chmod +x auto_shutdown.sh
This will set the execute bit and allow the system to process it as a program. Now you have your script, you just need something to execute that script at a predetermined time.
Launchd to schedule your job
launchd is the service management framework that starts/stops/restarts processes, services, daemons, etc. To set up a job to kick off with
launchd you need two items:
- type of job to be run; run as the user for one user, as the user for all users, or a job run by the system as
root. We want the last one.
plist (XML file) that describes the job. The key elements that you need to focus on right now are the
ProgramArguments that calls the script and the
CalendarInterval which specifies when the jobs should be run. For this example, call your plist
user.com.autoShutdown.plist (no other reason for that naming convention other than it follows Apple's conventions.)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
This plist is set to run the
auto_shutdown.sh script every day at 11:30pm.
Since we want to run this as root, copy the plist to the
$ sudo cp com.user.autoShutdown.plist /Library/LaunchDaemons
Finally, load the job into
$ sudo launchctl load com.user.autoShutdown.plist
That's it. Every day at 11:30, the system will automatically shutdown.
Replicate across all your machines
Copy both the script and plist to each machine and load the job into
launchd. You have just set the shutdown time for all machines and it didn't require 3rd party ($$$) utilities.
You can find info on all the commands listed here by looking up their man page. Type
man <command> for the command you're interested in.