- What is a Cron expression?
- A Cron expression is a string format used to configure scheduled tasks, consisting of 5 or 7 fields representing minute, hour, day, month, weekday (and optionally second and year). It allows you to precisely specify when a task should be executed.
- What's the difference between Linux and Quartz formats?
- Linux Cron format contains 5 fields (minute hour day month weekday) and is used by standard Unix/Linux systems. Quartz format contains 7 fields (second minute hour day month weekday year) and is primarily used in Quartz scheduler for Java applications, supporting second-level precision and year specification.
- How do I use this tool?
- You can use it in two ways: 1) Field Mode: Select values for each time field through the form; 2) Expression Mode: Directly enter a complete Cron expression. The tool automatically validates the expression and shows the next 5 execution times. You can also use preset templates to quickly generate common expressions.
- Why is my expression showing as invalid?
- An invalid expression may be caused by: 1) Incorrect number of fields (Linux format requires 5 fields, Quartz requires 7); 2) Field values out of valid range (e.g., minute > 59, hour > 23); 3) Unsupported characters or syntax; 4) Conflicts between day and weekday fields (some systems don't support specifying both). Please check the error message and correct the expression.
- How to handle timezone issues?
- Cron expressions use the timezone of the server where they run. If you're in a different timezone, you need to manually adjust the time values. For example, to execute a task at 9:00 AM Beijing time on a server in UTC+8, the hour field in the expression should be 1 (assuming the server uses UTC). It's recommended to carefully test timezone settings before deploying to production.
- What do special characters in expressions mean?
- Cron expressions support various special characters: * (matches all values), ? (no specific value, used in day or weekday fields), - (range, e.g., 1-5), , (list, e.g., 1,3,5), / (step, e.g., */5 means every 5 units). For example, "0 */2 * * *" means execute every 2 hours, "0 9 * * 1-5" means execute at 9 AM on weekdays.
- Can I execute tasks every second?
- Standard Linux Cron doesn't support second-level precision; the minimum unit is minutes. If you need second-level precision, you must use Quartz format (7 fields), where the first field is seconds. For example, "*/10 * * * * ? *" means execute every 10 seconds.
- How to copy and use the generated expression?
- Click the copy button on the right side of the expression, or use the copy button at the top of the tool, to copy the expression to your clipboard. Then add it to your crontab file (using crontab -e to edit) or use it in your application configuration. Remember to test in a test environment before deploying to production.