Understanding Cron Expressions and Linux Crontab
A **cron expression** is a string of five or six fields separated by white space that represents a schedule for executing a task or job. Cron jobs are widely used in Unix-like operating systems to run scripts, clean up databases, or trigger recurring actions at specific times or intervals.
Crontab Expression Syntax
Standard crontab format consists of 5 fields:
Supported Operators:
- * (Asterisk): Represents all values. E.g., "*" in the hour field means "every hour".
- , (Comma): Separates elements of a list. E.g., "1,3,5" in the hour field means "at 1 AM, 3 AM, and 5 AM".
- - (Hyphen): Defines ranges. E.g., "1-5" in the day of week field means "Monday to Friday".
- / (Slash): Specifies increments (steps). E.g., "*/15" in the minute field means "every 15 minutes".