Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between 'Day' and 'Weekday' in launchd StartCalendarInterval?

I'm working with launchd to run some automated tasks, and I was wondering what the difference is between 'Day' and 'Weekday'.

According to http://discussions.apple.com/thread.jspa?threadID=1361809 there is a 'subtle' difference that can cause launchd to misbehave.

Ultimately, I'd like to have a plist that runs every weekday (Mon - Fri) at 8am, but I don't know how to get the cron equivalent of

0 8 * * 1-5
like image 885
Joshua Kunzmann Avatar asked Aug 25 '10 23:08

Joshua Kunzmann


1 Answers

Day is the day of the month.

Weekday is the day of the week (0 and 7 == Sunday).

For you, you need:

<key>StartCalendarInterval</key>
<array>
    <dict>
        <key>Weekday</key>
        <integer>1</integer>
        <key>Hour</key>
        <integer>8</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
    <dict>
        <key>Weekday</key>
        <integer>2</integer>
        <key>Hour</key>
        <integer>8</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
    <dict>
        <key>Weekday</key>
        <integer>3</integer>
        <key>Hour</key>
        <integer>8</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
    <dict>
        <key>Weekday</key>
        <integer>4</integer>
        <key>Hour</key>
        <integer>8</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
    <dict>
        <key>Weekday</key>
        <integer>5</integer>
        <key>Hour</key>
        <integer>8</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
</array>

Not quite as elegant as cron...

like image 172
Will Hartung Avatar answered Oct 19 '22 12:10

Will Hartung