How can I make my Macbook automatically shutdown after a Time Machine backup?

I have a 40GB worth backup to do but I keep having to cancel it to go to bed. Would be great if I could leave it on to do it overnight.

Any suggestions of how to do this in ML?

  • Why do you have to cancel it to go to bed?
    – Gerry
    Commented Sep 11, 2012 at 20:16
  • Because I wouldn't want my Macbook on all night incase of overheating Commented Sep 11, 2012 at 20:19
  • 3
    Once it idles, it will go to sleep. You are overthinking this one.
    – Gerry
    Commented Sep 11, 2012 at 20:21
  • Set it to sleep even with power on after X minutes and let it run until done? Commented Sep 11, 2012 at 20:21
  • Doesn't sleeping still use a considerable amount of power resources? Commented Sep 11, 2012 at 20:29

3 Answers 3


You could setup a crontab to use tmutil through the command line to do a backup and then shutdown. since shutdown requires sudo privs, you have to set your crontab up as sudo.

sudo crontab -e

Enter your password and then that brings you to edit the contab file

shutdown -h now

Shutdown does exactly that but with the -h flag, it halts the system (shutdown). For the shutdown to work, this would have to be setup as an crontab under sudo

tmutil startbackup

Starts the timemachine backup.

Putting it all together:

00 20 ** ** ** tmutil startbackup --block && shutdown -h +5

Would do the backup at 10:00pm every day and then shutdown

  • Looking at the post by @da4 you could replace rsync with tmutil. I was unaware of their command line tool
    – slowBear
    Commented Sep 11, 2012 at 21:56
  • sudo zsh -c "tmutil startbackup --block && shutdown -h +5" to run it manually without any additional blocking password prompts. No need to setup crontab, if you don't need it. Commented Aug 15, 2022 at 21:46

I wanted to be able to leave an existing backup to complete, so my approach is a little different.

The backupd process seems only to be running whilst a backup is underway (and for a minute or two afterwards, from what I've observed) so I logged in as root (so that I can (a) see all users' process and (b) trigger a shutdown) and then polled for the process to finish before shutting down. So:

sudo -s

and enter your password to become root, then:

while ( ps -ef | grep 'backupd$' ); do echo "Still backing up..."; sleep 60; done; shutdown -h +1

to wait for backupd to finish and then shut down. (I used shutdown -h +1 instead of shutdown -h now just to be over-cautious and give it an extra minute to tidy up or whatever before shutting down.)

  • Unfortunatelyl, this didn't work for me. Although Time Machine finished the backup, ps -ef | grep 'backupd$' returns 0 213 1 0 Wed03PM ?? 119:47.66 /System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd, so the script cannot work. This is Big Sur 11.2.1 (20D74), using an external drive as Time Machine backup drive. Commented Feb 26, 2021 at 11:01
  • @MartinBraun Sorry to hear it doesn't work for you. My Mac can only run up to 10.11.6, sadly, so I can't check that out. I wonder if anyone else can confirm it doesn't work with that version...?
    – IpsRich
    Commented Mar 1, 2021 at 10:04

Assuming you have already set a destination for your TM, you could open a shell in Terminal (or ssh in), sudo su into super-user mode, then run tmutil startbackup --block;shutdown -h now;exit which tells TM to begin a backup immediately, turn off the Mac, and exit the shell. man tmutil for more info.

You could also then add this as a launchctl item or even cron it to schedule.

  • Be careful with this. I plugged my time machine drive in and ran this command. The time machine backup was already being prepared, so the tmutil errored out (saying a backup was in progress) and then the shutdown command was issued (which froze my laptop for some reason, I had to do a hard reset). Trying again now with no backup being prepared, fingers crossed! Commented Jan 19, 2015 at 11:16

You must log in to answer this question.

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