launchd job starts directly

Discussion in 'Mac Programming' started by bladepit, Nov 30, 2014.

  1. bladepit macrumors newbie

    Joined:
    Nov 30, 2014
    #1
    Trying to create a task that starts on every day at 4AM to restart my mac and execute some maintenance scripts. This is my script:

    Code:
    <?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>local.job</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/bin/osascript</string>
                <string>/Users/Media/Scripts/RestartMac.scpt</string>
        </array>
        <key>RunAtLoad</key>
        <false/>
        <key>StandardErrorPath</key>
        <string>/Users/Media/Scripts/Output/RestartMac.txt</string>
        <key>StandardOutPath</key>
        <string>/Users/Media/Scripts/Output/RestartMac.txt</string>
        <key>StartCalendarInterval</key>
        <array>
                <dict>
                        <key>Hour</key>
                        <integer>04</integer>
                        <key>Minute</key>
                        <integer>00</integer>
                </dict>
        </array>
    </dict>
    </plist>
    If i run launchctl unload / load to reload my plist file it will execute the script. I am a bit confused cause i have set the RunAtLoad parameter to false. Tried a lot of things but i am unable to get it running. Has anyone an idea what is my fault here?

    Operation system: OS X 10.9
     
  2. kryten2, Nov 30, 2014
    Last edited: Nov 30, 2014

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    The default of the RunAtLoad key is false. Things you can try :
    • remove the RunAtLoad key
    • try another label string
    • new plist with only label and programarguments
    • <array> not necessary when using only one calendarinterval
    • <integer>4</integer>
    • <integer>0</integer>
     
  3. bladepit thread starter macrumors newbie

    Joined:
    Nov 30, 2014
    #3
    Don't know why but this worked. Copied the plist file and just renamed it and changed the label.

    Thanks!
     

Share This Page