How Do I Get My Mac to Wake From Sleep for a Macro Triggered at a Specific Time

Hi @Unikitty. I have an old headless Mac mini that I wake at 2:00, 3:00, and 4:00 a.m. to do some routine tasks using Keyboard Maestro. I stripped out the tasks and created this template that you might want to try.


Cron Trigger—TEMPLATE

PURPOSE

The macro template includes actions that will run when:

  • This cron entry matches the current time , OR
  • any other configured trigger is detected (e.g., ⌃⌥F2).

In the former case, the Mac will be put the Mac to sleep unless another instance of this macro is started before this macro completes.

SCHEDULING A MAC TO WAKE

System Preferences > Energy Saver (or Battery) > Schedule > Start up or wake can be used to schedule only one startup time per day. If more times are needed, the command pmset can be used in combination with cron. Since pmset must be run as root to modify settings, the crontab command should be used as follows: sudo crontab

For example, if this template is copied to create macros that trigger 2:00, 3:00, and 4:00 a.m., the root contab file should be set as follows:

@reboot pmset repeat wakeorpoweron MTWRFSU 01:59:00
0 2 * * * pmset repeat wakeorpoweron MTWRFSU 02:59:00
0 3 * * * pmset repeat wakeorpoweron MTWRFSU 03:59:00
0 4 * * * pmset repeat wakeorpoweron MTWRFSU 01:59:00

TESTED WITH

• Keyboard Maestro 10.0.2
• Monterey, v12.3.1/MacBookPro16,1
• Mojave 10.14.16/Macmini6,2
• High Sierra 10.13.6/iMac11,1445

VERSION HISTORY

1.0 - Initial version


DOWNLOAD Macro File:
Cron Trigger—TEMPLATE.kmmacros (24 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Macro-image

2 Likes