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?
How to configure a complex launchd CalendarInterval
launchdplist
Related Question
- What are launchd’s LaunchAgents directories for
- MacOS – Why is the launchd job running at boot even with RunAtLoad key set to false
- Launchd notification on abnormal exit
- MacOS – Can’t get launchd task to run
- MacOS – Configure launchd
- MacOS – launchd runs program every hour even though StartCalendarInterval array is provided
Best 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: