Developer Tools

What Is Crontab and How Do Cron Jobs Work?

Cron schedules repeat commands at specified times. Crontab is where a user records those schedules on many Unix-like systems.

Cron is a time-based job scheduler commonly found on Unix-like systems. A cron job combines a schedule with a command. A crontab is a table of those entries, usually associated with a user or managed as a system file.

What the five crontab fields mean

A common user crontab entry starts with five schedule fields followed by the command:

minute hour day-of-month month day-of-week command

For example, 30 2 * * 1 /path/to/backup.sh requests the command at 02:30 on Monday in the scheduler's configured timezone. System crontab files can include an additional user field, and other schedulers may add seconds or years.

Asterisks, lists, ranges, and steps

  • * means every allowed value in that field.
  • 1,15 is a list of two values.
  • 1-5 is an inclusive range.
  • */30 uses a step, such as every 30 minutes within the field.

Do not assume every cron dialect interprets advanced syntax, names, shortcuts, or day fields identically. Read the documentation for the exact scheduler that will run the job.

Common five-field examples

ExpressionTypical meaning
*/30 * * * *Every 30 minutes
0 */2 * * *Every two hours at minute zero
0 9 * * *Daily at 09:00
0 0 1 * *At midnight on the first day of each month

How to edit and inspect cron jobs

On systems that provide the standard command, crontab -e opens the current user's crontab and crontab -l lists it. Administrative access, service configuration, containers, hosting dashboards, and managed platforms can use different locations or interfaces. Confirm where the job is actually installed before editing anything.

Test a cron job safely

  1. Run the command manually with the same user, working directory, permissions, and environment expected by cron.
  2. Use absolute paths for scripts and important files.
  3. Start with a harmless test output and a short temporary schedule.
  4. Capture standard output and errors in an approved log location.
  5. Confirm timezone, daylight-saving behavior, and missed-run behavior.
  6. Restore the intended schedule and monitor the first production runs.

Why a cron job may not run

Common causes include invalid syntax, a different timezone, a minimal environment, a missing executable path, file permissions, a stopped scheduler service, an unescaped percent sign in some implementations, or a command that assumes an interactive shell. A schedule builder can check field shape, but it cannot inspect the target server, command, logs, permissions, or scheduler configuration.

Cron versus application schedulers

Linux cron is useful for recurring local commands. Application queues, cloud schedulers, CI systems, and orchestration platforms can provide retries, distributed locks, monitoring, secrets, calendars, and missed-run policies. Choose the scheduler that matches the reliability and audit requirements of the task.