DevBox

What Is Cron? A Clear Guide to crontab and Expression Format

DevBox Team · Last updated 2026-07-01

Want to generate directly? Try Cron Expression Generator — fill in the form and get results instantly. Open tool →

What Is Cron

Cron is the background service on Linux, macOS, and other Unix-like systems responsible for running tasks on a schedule. You simply tell it “when to run and what command to run,” and it runs automatically at the specified time—no manual supervision needed. Common uses: automatically backing up a database in the early morning, cleaning up temporary files every hour, checking service status every minute, and so on.

crontab: cron’s Configuration

The configuration cron reads is called the crontab (short for cron table). At the same time, crontab is also the command used to manage this configuration:

  • crontab -e: edit the current user’s scheduled tasks
  • crontab -l: list existing scheduled tasks
  • crontab -r: delete all tasks (use with care)

Each line in a crontab = one cron expression + the command to run, for example:

0 3 * * * /usr/bin/backup.sh

This means: run /usr/bin/backup.sh every day at 3 AM. The leading 0 3 * * * is the cron expression, which describes “when.”

The Five Fields of a Cron Expression

A standard cron expression consists of 5 fields, separated by spaces. From left to right, they are:

PositionFieldRangeDescription
1Minute0-59Which minute
2Hour0-23Which hour (24-hour clock)
3Day of month1-31Which day of the month
4Month1-12Which month
5Day of week0-6Which weekday (0 = Sunday)

For example, 30 8 * * 1 means: every Monday at 8:30 AM.

Meaning of Special Characters

Within each field you can combine these symbols to build flexible time rules:

SymbolMeaningExample
*Every value (any value)* in the minute field = every minute
,Enumerate multiple values9,18 in the hour field = 9 AM and 6 PM
-Continuous range1-5 in the day-of-week field = Monday through Friday
/Step (every N)*/5 in the minute field = every 5 minutes

Combined example: */10 9-18 * * 1-5 means every 10 minutes between 9 AM and 6 PM on weekdays.

Common Pitfalls

  • Confusing “day of month” and “day of week”: when both are set to specific values, most systems run the task “if either matches,” which can trigger more often than expected. In everyday use, just use one of them.
  • Forgetting that commands need absolute paths: cron’s runtime PATH is very minimal, so it’s best to write python, node, etc. as full paths.
  • Writing seconds into the expression: standard cron has no seconds; if you need second-level precision, use a 6-field implementation (such as Quartz).

Next Steps

Now that you understand the format, you can:

FAQ

What is the difference between cron and crontab?

cron is the background service (daemon) responsible for "running things on a schedule"; crontab is the configuration file it reads, and also the command used to edit that file (crontab -e). The scheduling rules you write are stored in the crontab, and the cron service runs them on time.

How many fields does a cron expression have?

A standard cron has 5 fields: minute, hour, day of month, month, and day of week. Some systems (such as Quartz and Spring) use 6 fields, adding a "seconds" field at the front.

In the day-of-week field, do both 0 and 7 mean Sunday?

In most implementations 0 means Sunday; some also accept 7 for Sunday. For compatibility, it is recommended to consistently use 0 for Sunday.

More about Cron Generator