MacOS – Launchd to only run on schedule, not restart

launchdmacosplistschedule

I have a script that I want to set for 3:30am daily and it does run at the set time but it also runs on every restart of the computer which I do not want.

How do I make this work with just the schedule in place and not run on every startup of the computer?

Here's my 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>Label</key>
    <string>com.xxxxx.xxxx</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Library/Scripts/script.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Minute</key>
        <integer>30</integer>
        <key>Hour</key>
        <integer>3</integer>
    </dict>
</dict>
</plist>

Best Answer

You will need a add a "Run at Load" key and set it to false.

<key>RunAtLoad</key>
<false/>

This will prevent running at startup and only at your manually specified time.