Back

What Do the 5 Asterisks in Crontab Mean? (Basics of System Scheduling)

When managing servers, there are always tasks that need to be run periodically.

Cleaning up log files, backing up databases, and sending emails are classic examples. In Linux environments, the standard tool for scheduling these tasks is Cron.

However, to a beginner, a Cron expression can look like a cryptic code.

* * * * *

Let's decode what these 5 asterisks mean and discuss some common pitfalls.

1. Structure of Crontab Syntax

A standard Linux Cron expression consists of 5 fields.

*     *     *     *     *
Min   Hour  Day   Month Weekday
(0-59) (0-23) (1-31) (1-12) (0-7)
  • Minute: 0 to 59
  • Hour: 0 to 23
  • Day of Month: 1 to 31
  • Month: 1 to 12
  • Day of Week: 0 to 7 (Both 0 and 7 represent Sunday, 1=Monday, ...)

2. The Magic of Special Characters

Beyond simple numbers, you can use special characters for flexible scheduling.

  • * (Asterisk): Every value (every minute, every hour...)
  • , (Comma): List of values (e.g., 1,3,5 -> Run on 1, 3, and 5)
  • - (Hyphen): Range (e.g., 1-5 -> Run from 1 to 5)
  • / (Slash): Step values (e.g., */10 -> Run every 10 units)

Examples

  • 30 04 * * *: Run at 04:30 AM every day.
  • */15 * * * *: Run every 15 minutes (0, 15, 30, 45).
  • 0 9 * * 1-5: Run at 09:00 AM on weekdays (Mon-Fri).

3. Common Mistake: "Day" vs. "Weekday"

The most confusing part of Crontab configuration is the interaction between the "Day of Month" and "Day of Week" fields.

If both fields are set to specific values (not *), the command runs when EITHER condition is met (OR condition).

For example:
0 0 1,15 * 5

This runs on the "1st and 15th of every month" AND "every Friday". (It does NOT mean "run only on Fridays that fall on the 1st or 15th"!)

Conclusion

Cron is a simple yet powerful tool.

However, a misconfigured Cron job can exhaust server resources or cause critical backups to be missed.

For complex scheduling needs, always verify your expressions using online Crontab generators, or consider adopting professional scheduling tools like Jenkins or Airflow.

TechLinuxCronDevOps

Explore Related Tools

Try these free developer tools from Pockit