How to Schedule Tasks With Cron on Linux

Cron runs scheduled commands at fixed times or intervals using crontab syntax. Learn the five-field schedule format and how to add a cron job.

Published September 21, 2026

Cron is a Linux time-based job scheduler that runs commands automatically according to a schedule defined in a crontab file, using five fields for minute, hour, day, month, and weekday.

# Run every day at 2:30 AM
30 2 * * * /usr/bin/php /var/www/app/artisan backup:run

Steps

  1. Run crontab -e to open your user's crontab file in an editor
  2. Add a line with five schedule fields (minute, hour, day-of-month, month, day-of-week) followed by the command to run, using * as a wildcard for 'any'
  3. Save and exit — cron picks up the new schedule automatically, no restart needed

How it works

The five fields, in order, are: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-6, Sunday=0). '30 2 * * *' means minute 30, hour 2, every day/month/weekday — i.e. 2:30 AM daily.

Things to watch for

  • Cron jobs run with a minimal environment (no shell profile loaded) — always use full absolute paths to binaries and scripts inside a crontab entry
  • Redirect output to a log file (command >> /var/log/mycron.log 2>&1) since cron normally only emails output, which is often not configured on modern servers

FAQ

Why does my cron job work manually but fail when run by cron?

Almost always an environment issue — cron doesn't load your shell's PATH or environment variables. Use absolute paths for every binary and file referenced in the command.

More Linux articles