Paging the terminal experts: Scheduling a Mac to wake

So it seems that Apple dumped the schedule facility in the Energy Sver section of Preferences (WTF?) and it now has to be done in terminal. I’ve mostly got it, but need some help…

I want the Mac to wake or power on every day at 10am, 1pm, 4pm and 7pm. (I need this to happen so that scheduled emails are sent).

If I just wanted it to power on/wake at 10am I beleive the command looks like this…

sudo pmset repeat wakeorpoweron MTWRFSU 10:00:00

But to have it do the same at the other times, I’m not sure if I can add all the times to the one command, like this…
sudo pmset repeat wakeorpoweron MTWRFSU 10:00:00 13:00:00 16:00:00 19:00:00

Or, if I should do different command lines for each event.

Anyone know?

Thanks.

Hej, You should do a different command for each event.

First, set the Mac to wake or power on at 10am:
sudo pmset repeat wakeorpoweron MTWRFSU 10:00:00

Then, set it to wake or power on at 1pm:
sudo pmset repeat wakeorpoweron MTWRFSU 13:00:00

Similarly, set it for 4pm:
sudo pmset repeat wakeorpoweron MTWRFSU 16:00:00

And finally, for 7pm:
sudo pmset repeat wakeorpoweron MTWRFSU 19:00:00

Each time you issue the command, it will add the specified wake time to the schedule. The Mac will now wake or power on at all of those times.

To check your scheduled events, you can use the command:
pmset -g sched

This will display all scheduled power events.

6 Likes

Many thanks. Much appreciated.

Hi Kent, do you know if it’s possible to have the volume set to 0 (mute) at a regular time each day using Terminal?

I’ve worked out how to do it immediately…

sudo osascript repeat -e “set Volume 0”

But I can’t work out how to turn that into a daily repeat at 7pm. I’ve trtied a few things, but none have worked.

Thanks.

Hej

Yes you can make a cron job.
Open Terminal.
Type crontab -e and press Enter. This will open the crontab file for editing.
In the editor, add the following line:

0 19 * * * osascript -e “set volume output muted true”

This line means:

  • 0 minute
  • 19 hour (7pm in 24-hour format)
  • * every day of the month
  • * every month
  • * every day of the week

The command osascript -e "set volume output muted true" will mute the volume.

Save and exit the editor (if you’re in the vi editor, press Esc, then type :wq and press Enter).

That’s it! Your Mac should now mute its volume every day at 7pm.

Note: If you ever want to remove this schedule, you can type crontab -r in Terminal to remove your crontab entries. If you just want to edit or see them, use crontab -e or crontab -l respectively.

5 Likes

You’re a star. Thank you!

Had no idea you could set CRON jobs on a Mac. Used to them on the server, never a Mac.

Many thanks.

1 Like

Color me curious… What emails are you sending out from your Mac at those times?

Scheduled emails.

Etc.