Scheduled Restart Help

Lokua
New Contributor

Hey,

I found this script and made changes to reflect what I needed but it seems the StartCalendarInterval is not working. It triggers the first time but then it does not run again at the time its schedule even if the computer is awake. Iv tested by keeping it awake and changing the time on the mac. 

 

#!/bin/bash
echo "<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>com.Org.shutdown</string>
   <key>UserName</key>
   <string>root</string>
<key>Program</key>
<string>/sbin/shutdown</string>
<key>ProgramArguments</key>
<array>
    <string>/sbin/shutdown</string>
    <string>-r</string>
    <string>now</string>
</array>
<key>StartCalendarInterval</key>
<dict>
    <key>Weekday</key>
    <integer>5</integer>
    <key>Hour</key>
    <integer>3</integer>
    <key>Minute</key>
    <integer>00</integer>
</dict>
</dict>
</plist>" > /Library/LaunchDaemons/com.Org.shutdown.plist

chown root "/Library/LaunchDaemons/com.Org.shutdown.plist"
chmod 644 "/Library/LaunchDaemons/com.Org.shutdown.plist"
launchctl load -w "/Library/LaunchDaemons/com.Org.shutdown.plist"

 

1 REPLY 1

PaulHazelden
Valued Contributor

LaunchDaemons run once at boot. If you do not reboot the mac they do not run again, untill the Mac reboots.
I use a script to set powermanagement.

pmset repeat shutdown MTWRFS 21:00:00 wakeorpoweron MTWRFS 08:00:00
This wakes or boots at 08:00 in the mornings, on weekdays and Saturdays, and then shuts the Mac down at 21:00 on those same days.
To get rid of this use

pmset repeat cancel