Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.