Interview Prep/Shell Scripting/Scenarios: text processing and scheduling decisions

You are adding a new scheduled job on Ubuntu 24.04 servers. Cron or a systemd timer?

BeginnerScenarioScenarios: text processing and scheduling decisions
Answer

Situation read → Both work; timers give more operational features on systemd hosts.

What I'd do →

  1. Choose a systemd timer by default: logs in the journal, systemctl list-timers for next/last run, Persistent=true for missed runs, no overlapping runs, RandomizedDelaySec=, sandboxing, OnFailure= alerting.
  2. Choose cron when the job must be portable to non-systemd systems or containers, or the team manages crontabs centrally and the job is trivial.
  3. Either way: absolute paths, locking, timeouts, and logs.

Why → Timers solve most of the classic cron pain (environment surprises, silent failures, overlaps) out of the box.

Interview tip → Name three concrete timer advantages; "it's newer" is not an answer.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Scenarios: text processing and scheduling decisions