Introduction
In server administration, DevOps, and cloud scheduling, a cron job is a command line task scheduled to run automatically at specific intervals. The execution schedule is defined by a space-separated string of numbers and symbols called a cron expression.
While cron expressions are incredibly powerful, their syntax can be difficult for developers to parse at a glance. In this guide, we will break down standard cron formats, explain how wildcards work, and look at common configuration examples.
The 5-Field Standard Cron Format
Standard cron expressions contain 5 fields:* * * * *
Each field corresponds to a distinct time metric (from left to right):
- Minute: 0 - 59
- Hour: 0 - 23 (24-hour format)
- Day of Month: 1 - 31
- Month: 1 - 12 (or JAN-DEC)
- Day of Week: 0 - 7 (where 0 or 7 is Sunday, or SUN-SAT)
Special Wildcards and Characters
To create complex recurrence rules, cron syntax supports special operators:
- Asterisk (
*): Matches any value. An asterisk in the hour field means "run every hour". - Comma (
,): Defines a list of explicit values. E.g.,1,15,30in the minutes field. - Hyphen (
-): Specifies an inclusive range. E.g.,9-17in the hours field means every hour from 9 AM to 5 PM. - Slash (
/): Defines step increments. E.g.,*/15in the minutes field means "every 15 minutes".
Common Cron Schedule Examples
0 0 * * *: Runs once every day at midnight (12:00 AM).*/5 * * * *: Executes every 5 minutes.0 9 * * 1-5: Runs at 9:00 AM, Monday through Friday.30 18 1 * *: Executes at 6:30 PM on the 1st of every month.
Technical Implementation in TypeScript
Here is a secure client-side helper to describe simple cron expressions:
/**
* Safely parses and translates simple cron expressions into readable English.
* Runs completely client-side in the browser.
*/
export function describeCron(expression: string): string {
const parts = expression.trim().split(/\s+/);
if (parts.length !== 5) {
return 'Invalid cron expression: must contain exactly 5 space-separated fields.';
}
const [min, hour, dom, month, dow] = parts;
let timeStr = '';
if (min === '*' && hour === '*') {
timeStr = 'every minute';
} else if (min !== '*' && hour === '*') {
timeStr = `at minute ${min} of every hour`;
} else if (min !== '*' && hour !== '*') {
timeStr = `at ${hour.padStart(2, '0')}:${min.padStart(2, '0')}`;
}
let dateStr = '';
if (dom === '*' && month === '*' && dow === '*') {
dateStr = 'every day';
} else if (dow !== '*' && dom === '*') {
dateStr = `only on weekdays: ${dow}`;
}
return `Runs ${timeStr}, ${dateStr}.`;
}
Frequently Asked Questions
1. Does ToolSphere evaluate cron schedules on a server?
No. All translation and schedule checking execute locally in your browser sandbox.
2. Can I use the cron builder offline?
Yes. ToolSphere is fully client-side and functional offline.
Next Steps
To convert your cron strings into clear English sentences, check out the ToolSphere Cron Descriptor.