3

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>
1
  • I think I know the issue now. Can I flush launchd? I tested with one script and it was working on reboot. Then I adjusted the script with the schedule and it was still doing it on reboot. For a test I removed the launchd .plist task completely and restarted the computer and it still ran the script. So it seems to be remembering the task though I've deleted it. Can launchd be cleared or flushed as the .plist file is no longer there at all it it still runs?
    – Carter
    Commented Mar 11, 2015 at 17:24

2 Answers 2

4

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.

2
  • I added it as seen here but no luck. <dict> <key>RunAtLoad</key> <false/> <dict>
    – Carter
    Commented Mar 11, 2015 at 16:29
  • Once I figure-out how to clear/flush launchd I will try this again. Very well maybe working but don't know as the previous task is stuck/remembering it.
    – Carter
    Commented Mar 11, 2015 at 17:25
1

Thanks everyone just got this working! The first answer did work. My issue was that I didn't unload the first launchd .plist even though I deleted the file. It keep remembering it on each restart.

I ended up re imaging two iMacs and tested the launchd .plist with the added command.

Tested with loading it and unloading it to confirm. After countless reboots and adjusting the clock to then test over and over I can confirm its working the way we need it to :)

The computer can restart all it wants but will not run the script until the scheduled time.

1
  • 3
    Since answers can be sorted by votes, time or activity - please link to specific answers rather than saying "first". Also, if you could list the command you used to unload the plist - that will help people that arrive here later and can't understand what sequence actually resolved the issue.
    – bmike
    Commented Mar 12, 2015 at 15:22

You must log in to answer this question.

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