Cron Syntax Cheat Sheet: Format, Fields, Symbols & Examples
发布时间:2026-09-17 | 浏览:3
Use this cron syntax cheat sheet to decode the five fields, special symbols like *, /, -, and ,, common expressions, and copy-ready examples.
Cron syntax uses five time fields: minute, hour, day of month, month, and day of week, followed by the command. For example, 0 9 * * 1 runs at 9:00 AM every Monday.
The five cron fields are minute, hour, day of month, month, and day of week.
Use *, /, -, and , to express every value, steps, ranges, and lists.
Always confirm the server timezone before relying on a production cron schedule.
Master cron expressions with this comprehensive guide covering syntax, special characters, common patterns, and advanced techniques. From basic scheduling to complex automation scenarios.
📋 Field-by-Field Reference
Each cron expression consists of five time and date fields. Understanding each field's range and syntax is crucial for creating accurate schedules.
At minute 0 (start of hour)
Every 5 minutes
At minutes 15 and 45
Minutes 10 through 20
At midnight (12:00 AM)
At noon (12:00 PM)
Business hours (9 AM to 5 PM)
First day of month
15th day of month
June through August
Sunday (also 7)
Monday through Friday
Saturday and Sunday
⭐ Special Characters Reference
These special characters enable complex scheduling patterns and advanced time specifications.
Asterisk (Wildcard)
Matches any value in the field
Separates multiple values
Defines a range of values
Specifies step values or intervals
No specific value (some implementations)
Last occurrence (some implementations)
Nth occurrence of weekday (some implementations)
⚙️ Common Cron Job Macros
Modern cron implementations support convenient macros that replace common timing patterns.
🗓️ Common Scheduling Patterns
These frequently-used patterns cover most scheduling scenarios you'll encounter.
Daily at midnight
Daily maintenance tasks, backups, reports
Regular system checks, data synchronization
Every 15 minutes
Frequent monitoring, API health checks
Weekdays at 9 AM
Business hour tasks, sending daily reports
Sundays at 2 AM
Weekly maintenance, major backups
First day of every month
Monthly reports, billing processes
January 1st at midnight
Annual tasks, yearly archiving
Every 5 minutes during business hours
Active monitoring during work hours
💡 Advanced Cron Job Examples
Complex scheduling scenarios that demonstrate advanced cron syntax capabilities.
Complex Business Logic
Run at 8 AM, noon, and 5 PM on weekdays
Perfect for sending status updates at key business times
Quarterly Reports
9 AM on the first day of each quarter
Automatically generate quarterly business reports
Bi-weekly Tasks
Every other Sunday at midnight
For tasks that need to run every two weeks
Working Hours Monitoring
Every 10 minutes from 8 AM to 6 PM, weekdays only
Intensive monitoring during business operations
⚠️ Important Notes & Best Practices
Time Zone Considerations:
• Cron uses the system's local time zone
• Consider daylight saving time changes
• Use UTC for consistency across servers
• Document time zones in your cron jobs
Syntax Variations:
• Some systems support 6-field format (with seconds)
• Not all special characters work everywhere
• Test expressions on your specific system
• Check your cron implementation's documentation
🛠️ Validation & Testing
Before Adding to Crontab:
1. Test the command manually
2. Verify file paths are absolute
3. Check required permissions
4. Add proper logging and error handling
5. Use our cron generator to validate timing
Debugging Tips:
• Check cron daemon logs (/var/log/cron)
• Redirect output: command >> /var/log/job.log 2>&1
• Verify environment variables
• Test with simplified versions first
• Use mail output to catch errors
Ready to Create Your Cron Expression?
Use our interactive cron generator to build and validate expressions based on this syntax guide.
Bookmark this cheatsheet for quick reference when creating cron jobs.
Need more help? Check out our troubleshooting guide or explore detailed tutorials .
Cron Syntax Cheat Sheet: Format, Fields, Symbols & Examples FAQ
What does * mean in cron syntax?
An asterisk means every allowed value for that field. For example, * in the hour field means every hour.
What does */5 mean in a cron expression?
*/5 means every five values in that field. In the minute field, */5 runs at minutes 0, 5, 10, 15, and so on.
How many fields are in standard cron syntax?
Standard Unix cron syntax has five time fields plus the command. Some systems add a sixth seconds field or a username field.
Related Resources
Cron Every X Minutes: Expressions and Examples
Copy-ready cron expressions for */2, */5, */10, */15, */30 with explanations and tips to avoid pitfalls.
How to Write Cron Expressions: Complete Guide with Examples
Master cron expression syntax with our comprehensive guide covering the 5-field format, common patterns, examples, and best practices.
Ready to Create Your Cron Job?
Now that you understand the concepts, try our cron expression generator to create your own cron jobs!