Automatically scheduling shutdown of your Mac is useful for saving energy, managing tasks or simply following a schedule. Perhaps you don’t want to wait 30 more minutes for an app installation to finish or an online call to end. You can either schedule the shutdown to a specific time like 11PM or delay after a certain period like 30 minutes later. In this article, we will explain how to schedule shutdown efficiently on your Mac from Terminal app. If you do not like to use command-line interface, then check out scheduling shutdown in Mac using Shortcuts app.
Schedule Shutdown in macOS
There are three commands you can use to schedule shutdown in Mac:
- pmset command
- shutdown command
We will walk you through the steps with clear explanations and screenshots, ensuring that you can easily follow along, even if you’re not a tech expert. Make sure to save all your open documents and work before scheduling the shutdown.
Method 1: Scheduling Automatic Shutdown with pmset
Make sure you have administrator right and follow the below steps.
Terminal app is available under “Applications > Utilities” folder in Finder app. Alternatively, you can use Spotlight Search (by pressing “Command + Space” keys) to find and open Terminal app.
Now, to set the schedule, you can use a “pmset” command in Terminal. The pmset command in macOS is a command-line utility that allows you to control and configure power management settings of your Mac. You can use it to view, change, and manage various power-related settings, including sleep, restart, wake and more.
Below is the syntax of pmset command to schedule shutdown in Mac:
sudo pmset schedule shutdown "MM/DD/YYYY HH:MM:SS"
- Replace “MM/DD/YYYY” with your desired date in the mentioned format.
- Replace “HH:MM:SS” with your preferred time in the 24-hour format.
After typing the command press Enter to set the automatic shutdown schedule. For example, if you want your Mac to shutdown on September 16, 2023, at 18:00, you need to type the below command and press enter key.
sudo pmset schedule shutdown "09/16/2023 18:00:00"
It should look like below in your Terminal app:
You may need to enter administrator password if prompted to run the command.
Step 3 – Confirming the Schedule
To verify this scheduled event, you can check all the existing pmset schedules with the following command:
pmset -g sched
After executing this command, you will receive a list of events that have been scheduled using pmset. Among these events, you should find one corresponding to the shutdown scheduled for September 16th.
With this, you have successfully set up an automatic shutdown schedule on your Mac.
Step 4 – Canceling a Scheduled Shutdown
Now, you might be wondering how to cancel or remove this event. Well, If you decide to cancel the planned shutdown, again open Terminal app and use the following command:
sudo pmset schedule cancel 0
- cancel – indicates that you want to cancel a scheduled event.
- 0 – is the index of the scheduled shutdown in pmset. You can find this index number in front of the scheduled event with pmset -g sched command as explained above.
Instead of using index number, you can also use the exact time in pmset command in different syntax. For example, below is the command for cancelling the shutdown event planned on September 16th 18:00 hours.
sudo pmset schedule cancel shutdown "09/16/2023 18:00:00"
Here are some of the parameters you can use with pmset command to play around with the shutdown event in Mac:
- To make your Mac wake every Wednesday at 6:30 A.M., type:
sudo pmset repeat wake W 06:30:00.
- If you want your Mac to power on every weekday at 6:30 A.M., use:
sudo pmset repeat wake MTWRF 6:30:00.
- For a daily restart at 11:00 P.M., enter
sudo pmset repeat restart MTWRFSU 23:00:00.
As you can see, shutdown, restart and wake are the parameters to specify the type of event you’re triggering with pmset command.
Method 2: Using Shutdown Command from Terminal
You can also use the shutdown command from Terminal for halting, rebooting and sleeping. In this case, Mac will show a message and you have an option to include a custom warning message before triggering the shutdown.
2.1. Schedule Shutdown or Halt
Here is the format of the command:
sudo shutdown -h Delay_Time Custom Message
For example, if you want to delay after 2 minutes simply use the following command (Testing is the custom message).
sudo shutdown -h +2 Testing
After pressing enter key, type administrator password if prompted. Mac will show the final time of shutdown and process ID. You will see a notification like “System going down in 2 minutes” along with the custom warning message you have entered in the command. You can press enter again to return to the prompt.
You will get a final notification before 30 seconds and the system will be halted without any prompt. Therefore, make sure to save your work before scheduling shutdown from Terminal.
2.2. Check and Cancel Shutdown
For cancelling the schedule you need the process ID (pid) shown when you executed the shutdown command. Type the following command by replacing pid with your actual process ID number and press enter. Type your admin password if prompted and the scheduled shutdown will be cancelled.
sudo kill pid
If you have scheduled multiple shutdowns, then you can simply cancel all of them without using pid.
sudo killall shutdown
Note: If you did not notice that pid, simply type
top in the prompt and press enter. This will list all processes currently running on your Mac. Press “Command + F” to open the search box and type shutdown to find the shutdown command and the PID you have scheduled. However, this is difficult as there will be too many process running on your Mac and the display will change dynamically.
In this guide, we’ve walked you through two effective methods for scheduling automatic shutdown in your Mac. These two methods should work on all macOS versions. So, use one of the methods to avoid running the device continuously without shutting down and save some energy. It is also possible to trigger shutdown process immediately using the following command in Terminal. This command will show a prompt to save your work if there are any unsaved window there at that time.
osascript -e 'tell app "System Events" to shut down'