Choose Your Mac’s Sleep Cycle with Terminal Commands

Maintaining your personal sleep cycle can be a pain. We use sleep aids, drinks mantras, rituals, exercises, and other methods to lull ourselves into some shuteye. What all of these things amount to are little more than hacks for humans–little ways to try to manipulate our code to perform a command.

The same can be done with your Mac through its Terminal application. The biggest difference is, your Mac won’t be distracted by things like the computer because it is a computer and it’s completely unimpressed by the technology us humans use. This trick is a great way to regulate your computer’s sleep cycle. The trick comes in handy any time you’ll be spending an extended amount of time away from the device but need it to be up and running during certain hours of the day. Perhaps you run a local server off the computer that needs to be accessed during a dedicated time period, or maybe you just don’t want your Mac sleeping in all morning just because you’re not there. Regardless of the reason for it, this trick will keep your computer rising early in the morning and getting to bed right on time.

The first thing you’ll be tasked with doing is opening the Terminal, as that’s what you’ll be using to create your computer’s sleep schedule. The Terminal sits within the Utilities folder on your Mac, so find it and open it.

The first command will be to set up the sleep times for your Mac. To do this, type into the Terminal the following command:


Make sure to replace the date with whatever day is applicable to the cycle you’re creating using the full “Month/Day/Year” formatting. The time is dictated on a 24 hour clock, so 00:00:00 corresponds to midnight. 12:00:00 is noon, 22:00:00 is 10pm and so on.

Now that your Mac knows when to call it a night, it’s time to give it a wake up call. Once again you’ll be working within the terminal to dictate the time. To set the alarm for your Mac, use this command:


This command will ensure that your Mac will be up at the time that you decide for it. Macs don’t have the ability to hit the snooze alarm, so you’ve guaranteed your computer will be awake right when you expect it to be.

That’s all there is to it. Your Mac now has a dedicated sleep cycle for the day. You can, of course, duplicate these commands to create a schedule for longer absences. If you’d like to make this command part of your Mac’s daily routine, you can use the “repeat” command. For waking your computer at the same time every day, type this command in the Terminal:


You can choose the days you want this to happen by simply picking the dates out of the command “MTWRFSU”. If you just want the wake to occur on Monday, Wednesday, and Friday, just use the “MWF” part of the command.

Similarly, you can repeat the sleep schedule by using the repeat command. To make your Mac take a little nap at the same time every Tuesday, Thursday, and Sunday, you’d type the command as follows:


Now your Mac won’t spend those late nights stirring at all hours and will maintain a consistent cycle of sleep according to your dictation.

Image credit: Time