Cron Expression Tester
A powerful cron expression validator with real-time schedule preview. Features include common pattern presets, detailed field explanations, and Google Calendar integration for easy schedule management.
Cron Expression Tester
Test your cron expressions and see when they will run next.
Cron Expression
Enter a cron expression to test.
Presets
Use these presets to quickly set up common scheduling patterns.
Schedule
Check the next execution times of your cron expression.
And you can register to Google Calendar on .
Cron Expression Tips & Patterns
Master cron scheduling with practical examples, avoid common timezone pitfalls, and learn advanced patterns for complex scheduling needs.
While cron is ubiquitous, modern alternatives offer significant advantages:
- GitHub Actions: Scheduled workflows with version control
- Kubernetes CronJobs: Container-based with better isolation
- AWS EventBridge: Serverless with built-in retry logic
- Temporal/Airflow: Complex workflows with dependencies
- systemd timers: Better logging and dependency management
Use traditional cron only for:
- Simple system maintenance on single servers
- Legacy systems that can't be migrated
- Quick local development tasks
Most workflow tools support cron syntax, making migration easier!
Most cron failures are due to environment or path issues:
- PATH not set: Cron uses minimal PATH, commands may not be found
- Wrong permissions: Script must be executable (chmod +x)
- Relative paths: Always use absolute paths in scripts
- Missing shebang: Start scripts with #!/bin/bash
- Cron not running: Check with systemctl status cron
Debug tip: Redirect output to a log file: * * * * * /path/to/script.sh >> /tmp/cron.log 2>&1
Cron uses the system timezone by default, which causes issues:
- Jobs run at unexpected times after DST changes
- 2 AM jobs may run twice or not at all during DST transitions
- Different servers may run jobs at different UTC times
Best practices:
- Use UTC for all cron jobs to avoid DST issues
- Set system timezone to UTC on servers
- For Kubernetes: use
spec.timeZone: "UTC"
- Restart cron after timezone changes
Monthly patterns:
- 1st of month:
0 0 1 * *
- 15th of month:
0 0 15 * *
- Last day: Complex, use script logic or multiple entries
- 1st and 15th:
0 0 1,15 * *
Quarterly patterns:
- First day of quarter:
0 0 1 1,4,7,10 *
- Last day needs multiple entries:
0 0 31 3,12 *
(Mar 31, Dec 31)0 0 30 6,9 *
(Jun 30, Sep 30)
Both run every 5 minutes, but there's a subtle difference:
*/5 * * * *
- Every 5 minutes starting from 00,5,10,15,20,25,30,35,40,45,50,55 * * * *
- Same result, but explicit
Step values are cleaner for:
- Every 2 hours:
0 */2 * * *
- Every 3 days:
0 0 */3 * *
- Every 10 minutes:
*/10 * * * *
Note: */5
in hour field means hours 0,5,10,15,20, not "every 5 hours"!
When both day fields are set, cron runs on EITHER condition (OR logic):
0 0 13 * 5
runs on 13th AND on Fridays- NOT just "Friday the 13th"
- This is often unexpected behavior
Solutions:
- Use only one day field when possible
- For "2nd Tuesday": Use date logic in your script
- Some systems support:
0 0 8-14 * 2
for 2nd Tuesday
Concurrent execution can corrupt data or waste resources:
- Use lock files: Create a PID file at start, remove at end
- flock command:
flock -n /tmp/job.lock command
- systemd timers: Better handling of overlaps
- Job queues: Use Redis/RabbitMQ for complex workflows
Example with flock:
*/5 * * * * /usr/bin/flock -n /tmp/myjob.lock /path/to/script.sh
This skips execution if previous instance is still running.
Many cron implementations support special strings:
@reboot
- Run at startup@yearly
or@annually
- 0 0 1 1 *@monthly
- 0 0 1 * *@weekly
- 0 0 * * 0@daily
or@midnight
- 0 0 * * *@hourly
- 0 * * * *
Note: Not all systems support these. Kubernetes CronJobs don't support @ syntax.