I have a job that needs to run every hour between 09:00-15:00 M-F. How do I do that in a launchd plist file?
1 Answer
You'll have to explicitly create a record for every hour from 9 to 15 for every day from Monday to Friday: 35 records. The cron utility has a far more compact format. With it your use case would be written as 0 9-15 * * 1-5
. LaunchControl is a utility which creates launchd StartCalendarInterval records from cron time descriptions:
-
-
Thanks for the lead on LaunchControl! I've been using Lingon-X. I like LaunchControl more! May 11, 2017 at 13:39
-
FWIW, here is the scripted solution for the
StartCalendarInterval
array to create the schedule:for ((day=1;day<=5;day++)); do for ((h=9;h<=15;h++)); do echo "<dict> <key>Hour</key> <integer>$h</integer> <key>Minute</key> <integer>0</integer> <k ey>Weekday</key> <integer>$day</integer> </dict>"; done; done
. Pasted that output to the<array>
of theStartCalendarInterval
array, saved, and voila May 15, 2017 at 14:22