1

Scenario: I need to force a reboot as a Launch Daemon at a specific time only on Saturdays and Sundays.

Output

The reboot command gets launched at the specific time everyday instead only on Saturdays and Sundays. LaunchControl GUI even reads the plist for Saturdays and Sundays, yet the output the .plist is launched everyday.

The .plist

    <?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>RunAtLoad</key>
    <false/>
    <key>EnviromentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:</string>
    </dict>
    <key>Label</key>
    <string>com.test.restartschedule</string>
    <key>ProgramArguments</key>
    <array>
        <string>/sbin/shutdown</string>
        <string>-r</string>
        <string>now</string>
    </array>
    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Hour</key>
            <integer>23</integer>
            <key>Minute</key>
            <integer>35</integer>
            <key>WeekDay</key>
            <integer>6</integer> 
        </dict>
        <dict>
            <key>Hour</key>
            <integer>23</integer>
            <key>Minute</key>
            <integer>35</integer>
            <key>WeekDay</key>
            <integer>7</integer>
        </dict>
    </array>
    <key>StandardErrorPath</key>
    <string>/var/log/RestartScheduleError.log</string>
    <key>StandardOutPath</key>
    <string>/var/log/RestartSchedule.log</string>
</dict>
</plist>
  • 1
    The key for specifying day of the week is Weekday, not WeekDay. Launchd may not recognize the capital-D keyword, and might be ignoring it. – Ted Wrigley Jan 15 at 14:52
  • @TedWrigley I'm not sure whether to cry or laugh...but yes that was the reason for the issue. Thank you for pointing it out! – DankDalf Jan 16 at 13:01
  • Dude, if I could get back every hour I've seen hunting down typos in code, I'd probably be 14 again. 😀 – Ted Wrigley Jan 16 at 15:33
0

As Ted Wrigley stated: "The key for specifying day of the week is Weekday, not WeekDay. Launchd may not recognize the capital-D keyword, and might be ignoring it."

After correcting the key, launchd is now not triggering everyday.

You must log in to answer this question.

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