2

I have my StartCalendarInterval set in my launchd plist file like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>local.script.launcher</string>
        
        <key>Program</key>
        <string>/usr/bin/osascript</string>
        
        <key>ProgramArguments</key>
        <array>
            <string>osascript</string>
            <string>/Users/me/basic-script.scpt</string>
        </array>
        
        <key>StartCalendarInterval</key>
        <array>
            <dict>
                <key>Hour</key>
                <integer>8</integer>
                <key>Minute</key>
                <integer>0</integer>
            </dict>
            <dict>
                <key>Hour</key>
                <integer>16</integer>
                <key>Minute</key>
                <integer>0</integer>
            </dict>
            <dict>
                <key>Hour</key>
                <integer>24</integer>
                <key>Minute</key>
                <integer>0</integer>
            </dict>
        </array>
    </dict>
</plist>

Even though I am declaring 3 different StartCalendarIntervals, the agent still launches the program every hour.

What am I doing wrong?

.

SOLUTION:

As per @Phong's answer, for launchd plist files and StartCalendarInterval, midnight, 12AM, or 2400 hours military time is Hour = 0 not 24.

5
  • 2
    Please post the whole plist file, as other parts of the file could be the cause of the problem.
    – jksoegaard
    Aug 8, 2016 at 8:00
  • Updated. I figured anyone that tries to help will want to see it, but Stack wouldn't let me post it as it said "too much code." Aug 8, 2016 at 19:26
  • 2
    For Hour, you'll want to specify 0 rather than 24. I can't check right now, but I'm guessing it's throwing out the 24 as invalid, and just running on Minute 0. Also, you've unloaded and reloaded the agent after editing the plist?
    – user11633
    Aug 8, 2016 at 19:33
  • 1
    Sweet! I will try it an let you know later today. Def unloaded/loaded and then restarted Aug 8, 2016 at 20:23
  • @AndreBulatov Please post it to pastebin and link it here!
    – klanomath
    Aug 8, 2016 at 20:31

1 Answer 1

4

launchd is throwing out 24 as an invalid Hour value, thus interpreting that entire entry as Minute = 0. This causes your agent to run every hour on the dot.

The correct value for midnight is 0:

<dict>
    <key>Hour</key>
    <integer>0</integer>

    <key>Minute</key>
    <integer>0</integer>
</dict>
1
  • 1
    Haven't reached midnight yet, but can already confirm that it resolved the problem because the hourly runs stopped and when I changed from 24 to 0, I also added an entry for 11PM(23) and that worked perfectly. Thank you! Aug 9, 2016 at 3:33

You must log in to answer this question.

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