If you’re using macOS and want to schedule tasks like backups, notifications, or automation scripts, cron is a simple, built-in way to do it, no third-party apps required.
This guide walks you through setting up and verifying scheduled jobs.
What Cron Does
Cron lets you run commands or scripts at scheduled times. It’s great for:
- Automating reports or file processing
- Running shell or Python scripts on a timer
- Managing cleanup tasks
- Scheduling anything you’d normally type in Terminal
Sample Cron Jobs
Run a script every weekday at 3:30 PM:
30 15 * * 1-5 /Users/yourname/scripts/myscript.sh >> /Users/yourname/scripts/logs/weekday.log 2>&1
Run the same script at 10:00 AM on weekends:
0 10 * * 6,7 /Users/yourname/scripts/myscript.sh >> /Users/yourname/scripts/logs/weekend.log 2>&1
Tip: Always use full (absolute) paths in cron. It does not load your normal terminal environment.
How to Edit Your Crontab
Open Terminal and type:
crontab -e
On first use, you’ll be asked to choose an editor, select nano unless you’re familiar with vim.
Paste your schedule entry and save the file.
How to Verify Cron is Running
To see if your cron job has triggered:
grep CRON /var/log/system.log
You can also check your custom log file:
cat /Users/yourname/scripts/logs/weekday.log
Common Pitfalls
- Use absolute paths for all commands, scripts, and log files.
- Cron does not use your normal shell config (
.zshrc,.bash_profile, etc.) - If you use Python, make sure your
.shscript activates the virtual environment.
Example: Daily Script Automation
Here’s one I use to automate a task on weekdays:
30 15 * * 1-5 /Users/yourname/scripts/daily_report.sh >> /Users/yourname/scripts/logs/report.log 2>&1
You can apply this same structure to anything. Python scripts, database exports, cleanup jobs, and more.
Related Example (Optional)
If you’re curious how this applies in real life, I use cron to automate a YouTube bot I built:
AyotteDev/youtube-comment-bot on GitHub
Related Forum Post
Want to see how this cron setup was used in a live project?