Guide des expressions cron : syntaxe, exemples et generateur
Apprenez la syntaxe cron etape par etape. Generateur visuel en ligne.
What is a cron expression and what it's for
A cron job is a scheduled task that runs automatically on Unix/Linux. The cron expression defines WHEN it runs.
Format: * * * * * (5 space-separated fields): minute hour day-of-month month day-of-week.
Quick examples: 0 9 * * * = daily 9AM. */15 * * * * = every 15 min. 0 0 * * 0 = Sundays midnight. 0 0 1 * * = 1st of each month.
Generate cron expressions visually with the NexTools cron generator.
Cron syntax explained field by field
| Field | Values | Special chars |
|---|---|---|
| Minute | 0-59 | * , - / |
| Hour | 0-23 | * , - / |
| Day of month | 1-31 | * , - / |
| Month | 1-12 or JAN-DEC | * , - / |
| Day of week | 0-7 (0,7=Sunday) or SUN-SAT | * , - / |
* = any. , = list. - = range. / = step.
Common cron expression examples
| Expression | Meaning |
|---|---|
0 * * * * | Every hour on the hour |
*/5 * * * * | Every 5 minutes |
0 9 * * 1-5 | Weekdays at 9 AM |
0 0 * * * | Daily at midnight |
0 6,18 * * * | 6 AM and 6 PM daily |
0 0 1 * * | First of each month |
0 0 1 1 * | January 1st (yearly) |
0 9-17 * * 1-5 | Hourly 9AM-5PM weekdays |
Convert times between zones with the NexTools timezone converter.
How to use the NexTools cron generator
The NexTools cron generator: select frequency with visual controls, see generated expression, get human-readable description, copy for crontab/CI/CD. Also paste existing expressions to see their meaning.
Cron in practice: crontab, CI/CD, and cloud
Linux: crontab -e to edit. 0 9 * * * /usr/bin/python3 backup.py
Vercel: vercel.json crons config.
GitHub Actions: on: schedule: - cron: '0 9 * * 1-5'
AWS CloudWatch: 6-field cron (adds seconds or year).
Important: Cron jobs use server timezone (usually UTC). Use the timezone tool for correct UTC time.
Common cron job mistakes
1. Wrong timezone. Server is UTC but you wrote local time.
2. DST ambiguity. 2:30 AM cron runs 0 or 2 times on DST change. Use UTC.
3. Not redirecting output. Without > /dev/null 2>&1, output goes to system email.
4. Wrong path. Cron doesn't load user PATH. Use absolute paths.
5. Permissions. Script must be executable.
Modern alternatives to cron
systemd timers: Modern cron replacement on systemd systems.
Vercel Cron Jobs: Serverless function scheduling.
GitHub Actions: Free for public repos.
Cloud Scheduler (GCP), EventBridge (AWS): Managed scheduling.
BullMQ (Node.js): Job queue with cron-based scheduling.
6 and 7 field cron: non-standard variants
6 fields (seconds): sec min hour day month dow. Spring Boot, Quartz (Java).
7 fields (year): AWS CloudWatch.
@keywords: @yearly, @monthly, @weekly, @daily, @hourly, @reboot.
The NexTools generator supports standard 5-field syntax.
Essayez cet outil :
Ouvrir l'outil→Questions fréquentes
What does */5 mean in a cron expression
The / indicates step/increment. */5 in the minute field means 'every 5 minutes' (0, 5, 10, 15...). */15 = every 15. */2 = every 2 units.
How do I run a cron every 30 seconds
Standard cron doesn't support sub-minute intervals. Options: run every minute with sleep ('command && sleep 30 && command'), use systemd timer, or use a loop with sleep in the script.
What timezone do cron jobs use
Server timezone, usually UTC. Verify with 'date'. To avoid DST confusion, configure crons in UTC.
How do I debug a cron that doesn't run
Check: (1) script works manually, (2) absolute paths, (3) permissions, (4) cron service active, (5) cron logs (/var/log/syslog or /var/log/cron), (6) redirect output to file for errors.
Can I use month and day names in cron
Yes. Month: JAN-DEC. Day: SUN-SAT. '0 9 * * MON-FRI' = weekdays 9AM. Numbers are more universally supported.
What if a cron job overlaps with the next execution
Cron does NOT wait for previous execution. A 2-minute job scheduled every minute will have 2 instances running. Solution: use flock for locking to prevent overlap.