Automating with crontab

The manuals state that cron is a “daemon to execute scheduled commands” and crontab exists to “maintain crontab files for individual users.”

Basic usage

# Edit
crontab -e

# List
crontab -l

# Remove
crontab -r

Syntax

*    *    *    *    *    USERNAME command-path args
|    |    |    |    |
|    |    |    |    day of the week ( 0 - 6 )
|    |    |    month ( 1 - 12 )
|    |    day of the month ( 1 - 31 )
|    hour ( 0 - 23 )
minute ( 0 - 59 )

Troubleshooting

Bin path

Difference Between bin and sbin

Cron file not saving

Newly introduced security features in macOS Catalina require that the cron location (most likely /usr/sbin/cron) be added to the Full Disk Access list located at Apple menu () > System Preferences… > Security & Privacy > Full Disk Access.

Todo

  • Need to research crontab vs launchd

Resources