3

I have a script that LaunchControl runs in the middle of the night to back up my database and send a message that it has been done. The message is sent as follows:

osascript -e 'tell application "Messages" to send "backup completed" to buddy "admin"'

I am running macOS Mojave. This works fine if I test it during the day, but in the middle of the night it, the message is not sent even thought the backup occurs. Presumably it has something to do with the fact that my machine is asleep. How do I fix this?

  • Don't let the machine fall asleep :-) Backup is triggered by PowerNap, but this doesn't work for user-supplied functionality. – nohillside Aug 21 at 6:56
  • Any way to programmaticaly wake it up? – Obromios Aug 21 at 7:07
  • Have a Raspberry running in the network to send WOL packets maybe – nohillside Aug 21 at 7:48
4

The Mac must be powered on to run your script. Only a few Apple specific processes are allowed to run via PowerNap.

pmset

You can use pmset to schedule your Mac to wake in the middle of the night.

pmset allows you to schedule system sleep, shutdown, wakeup and/or power on. "schedule" is for setting up one-time power events, and "repeat" is for setting up daily/weekly power on and power off events. Note that you may only have one pair of repeating events scheduled - a "power on" event and a "power off" event. For sleep cycling applications, pmset can schedule a "relative" wakeup or poweron to occur in seconds from the end of system sleep/shutdown, but this event cannot be cancelled and is inherently imprecise.

  • type - one of sleep, wake, poweron, shutdown, wakeorpoweron
  • date/time - "MM/dd/yy HH:mm:ss" (in 24 hour format; must be in quotes)
  • time - HH:mm:ss
  • weekdays - a subset of MTWRFSU ("M" and "MTWRF" are valid strings)
  • owner - a string describing the person or program who is scheduling this one-time power event (optional)

See How to Power On Your Mac at a Specific Date and Time for more details, including a graphical approach, and alternative tools.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .