Suspending Ubuntu on a Mac Mini and Automatically Restarting

I want my Mac Mini with Ubuntu 13.04 Server installed on it to automatically suspend and re-start early in the morning. It does nothing all night so I didn’t see the point of it sitting there drawing power the whole time. So, how hard could it be I wondered? We’ll it turns out it was surprisingly easy. Before I did anything I wanted to make sure that the Mac could be suspended successfully. I did this easily enough with pm-is-supported:

pm-is-supported --suspend && echo "suspend is supported" || echo "suspend is not supported"

Happily enough that reported back that suspend is supported. After a bit of Googling and I came up with this page on Ask Ubuntu. I pretty much followed the instructions verbatim by creating the suspend_until script and adding a cron job to trigger it.

The suspend_until script in nano

The suspend_until script in nano

I made two changes to the script (which you can see above). The first was to use to use the -u flag on the rtcwake call because it turns out the real time clock in the Mac uses UTC time. The second was to use the disk rather than the mem suspend option. My reasoning was simply that a disk suspend is recoverable case of an extended power failure while a mem suspend is not. And here’s the CRON entry I made to suspend the Mac at 10:00PM each night and start up again at 6:30AM.

00 22 * * * /root/suspend_until 06:30
This entry was posted in linux on by .

About markn

Mark is the owner and founder of Timesheets MTS Software, an mISV that develops and markets employee timesheet and time clock software. He's also a mechanical engineer, father of four, and a lifelong lover of gadgets.