Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like LaunchD to launch a script every other week. The following works fine for every week, but how can I schedule it to only run every other week?

<?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>Program</key>
        <string>/scripts/autoSample</string>
        <key>AbandonProcessGroup</key>
        <true/>
        <key>Debug</key>
        <true/>
        <key>StartCalendarInterval</key>
        <dict>
                <key>Weekday</key>
                <integer>0</integer>
                <key>Minute</key>
                <integer>40</integer>
                <key>Hour</key>
                <integer>8</integer>
        </dict>
        <key>Label</key>
        <string>autoSample</string>
</dict>
</plist>
share|improve this question

How about using a StartInterval of 2 weeks (1209600 secs) instead?

<?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>Program</key>
        <string>/scripts/autoSample</string>
        <key>AbandonProcessGroup</key>
        <true/>
        <key>Debug</key>
        <true/>        
        <key>StartInterval</key>
        <integer>1209600</integer>
        <key>Label</key>
        <string>autoSample</string>
</dict>
</plist>
share|improve this answer
    
If I understand correctly that would only work if I timed the loading correctly. A reboot would also break it, wouldn't it? -- Thanks though – Dave Albert Apr 5 '13 at 9:25
    
Yes, you're right. Here's another idea: what about your original StartCalendarInterval, then adding a ThrottleInterval of over 1 week? – Colin Pickard Apr 5 '13 at 9:34

You could add something like this to the start of the program:

(($(date +%V) % 2 == 0)) && exit
share|improve this answer

You must log in to answer this question.

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