in Computing

Schedule jobs with “at” on macOS Mojave

For when scheduling jobs with cron is a kludge, we have at to quickly schedule a one-off shell script for execution at a later time. The problem is that on macOS Mojave with the introduction of new privacy controls, jobs scheduled with at silently fail.

The symptom belies the purpose of scheduling a job in the future: your neatly scheduled job (echo "rm ~/Documents/taxreturn" | at noon) does not run at noon when you scheduled it and ~/Documents/taxreturn still exists. By observing the system logs, we can observe that atrun needs the kTCCServiceSystemPolicySysAdminFiles permission. The solution is to add and enable /usr/libexec/atrun to the Full Disk Access list in the Privacy tab of the Security & Privacy preference pane.

Also, while not a new issue in Mojave, do not forget to load the atrun launchd job as suggested by its man page.

sudo launchctl enable system/com.apple.atrun
sudo launchctl bootstrap system /System/Library/LaunchDaemons/com.apple.atrun.plist

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.