Sign up ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

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

3 Answers 3

up vote 1 down vote accepted

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

share|improve this answer
Looking at the post by @da4 you could replace rsync with tmutil. I was unaware of their command line tool – slowBear Sep 11 '12 at 21:56

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.

share|improve this answer
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! – Chris Parton Jan 19 at 11:16

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.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.