Logo Odhy Pradhana

CRON Basics

Posted: Jul 31, 2025

Updated: Jul 31, 2025

CRON is a time-based job scheduler in Unix-like OS. It allows users to run scripts or commands automatically at specified times and intervals.

CRON Expression Format

Each CRON job uses a 5-field format:

* * * * * command\_to\_run
| | | | |
| | | | └── Day of the week (0-7) (Sunday = 0 or 7)
| | | └──── Month (1-12)
| | └────── Day of the month (1-31)
| └──────── Hour (0-23)
└────────── Minute (0-59)

Examples

ScheduleCRON ExpressionDescription
Every minute* * * * *Runs every minute
Every day at 7 AM0 7 * * *Runs daily at 07:00
Every Monday at 9 AM0 9 * * 1Runs every Monday at 09:00
First day of month0 0 1 * *Runs monthly at midnight on the 1st
Every 15 minutes*/15 * * * *Runs every 15 minutes

Special Strings

CRON also supports special time strings:

StringEquivalent
@rebootRun once at startup
@daily0 0 * * *
@weekly0 0 * * 0
@monthly0 0 1 * *
@yearly0 0 1 1 *

Notes

  • Use absolute paths in the commands (e.g., /usr/bin/python3 /home/user/script.py)
  • CRON uses the system’s timezone, verify it with timedatectl
  • Test schedule using crontab.guru