macOS CRON

CRONTAB on macOS

It’s annoying on macOS that each editing would prompt the pop up for authorization of scheduled task.

.plist What is it?

To load/unload a plist

1
2
launchctl load ~/Library/LaunchAgents/test.plist
launchctl unload ~/Library/LaunchAgents/test.plist

Due to the limitations of recent macOS updates, it’s getting increasingly difficult to run a small command via shell, which is totally understandable at a security standpoint.

Therefore, we need to use the Automator.app from Apple to essentially run any scripts (fixed) daily.

Example.plist which runs daily at 09:27

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?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>Label</key>
    <string>test.label</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/open</string>
        <string>-a</string>
        <string>/Applications/Backup Brewfile.app</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>09</integer>
        <key>Minute</key>
        <integer>27</integer>
    </dict>
</dict>
</plist>

Example app

Ref:

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy