How do you schedule recurring tasks with cron and what are common pitfalls?
Assesses fundamental understanding of Linux Administration conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
cron runs commands on a schedule defined by five time fields: minute, hour, day of month, month and day of week.
# m h dom mon dow command
30 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
Common pitfalls:
- cron uses a minimal environment, so PATH and variables from your shell are absent. Use absolute paths or set PATH at the top of the crontab.
- Redirect stdout and stderr or you lose the output.
- Jobs run concurrently if the previous run overruns; guard with flock.
- The percent sign is special and must be escaped.
- Timezone depends on the system or CRON_TZ.
For complex schedules, prefer systemd timers, which offer logging through journald, dependency handling and better observability.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.