BeginnerPhone
2 min
Cron Expression Basics
LinuxAutomationScheduling
Advertisement
Interview Question
What does the cron expression "0 2 * * 1-5" mean, and how would you test a cron job locally?
Key Points to Cover
- "0 2 * * 1-5" runs at 02:00 Monday–Friday
- Fields: min hour dom month dow
- Test via `crontab -l`, `cron` logs, or run the script directly with a dry run flag
Evaluation Rubric
Parses cron fields correctly40% weight
Explains the schedule accurately30% weight
Mentions safe testing approaches30% weight
Hints
- 💡Remember DOW ranges and local time considerations.
Common Pitfalls to Avoid
- ⚠️Misinterpreting the day of week values (e.g., confusing 0/7 for Sunday or swapping Monday-Friday range).
- ⚠️Failing to clearly explain what each of the five fields (minute, hour, day of month, month, day of week) represents.
- ⚠️Not specifying 'AM' when interpreting the hour field, or generally lacking precision in the time component.
- ⚠️Confusing the 'day of month' field with the 'day of week' field, or vice versa.
- ⚠️Only providing the final interpretation without breaking down how each component contributes to the schedule.
Potential Follow-up Questions
- ❓How do you ensure idempotency?
- ❓What about timezone handling in cron?
Advertisement