How to Use Cron on macOS to Schedule Scripts Automatically

:three_o_clock: How to Use Cron on macOS to Schedule Scripts Automatically

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.


:white_check_mark: 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

:hammer_and_wrench: Sample Cron Jobs

:date: 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

:date: 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

:pushpin: Tip: Always use full (absolute) paths in cron. It does not load your normal terminal environment.


:writing_hand: 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.


:test_tube: 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

:warning: 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 .sh script activates the virtual environment.

:brain: 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.


:paperclip: Related Example (Optional)

If you’re curious how this applies in real life, I use cron to automate a YouTube bot I built:

:link: AyotteDev/youtube-comment-bot on GitHub

:thread: Related Forum Post

Want to see how this cron setup was used in a live project?

:backhand_index_pointing_right: How I Automated YouTube Comment Promotion (and What Else I Did Today)