Interview Prep/Linux/Scheduling, automation and scripting

Convert that nightly cron job to a systemd timer. Why would you?

IntermediateScenarioScheduling, automation and scripting
Answer

Situation read → Timers add logging, dependencies and catch-up runs.

What I'd do → /etc/systemd/system/db-dump.service:

[Service]
Type=oneshot
User=postgres
ExecStart=/usr/local/bin/db-dump.sh

/etc/systemd/system/db-dump.timer:

[Timer]
OnCalendar=*-*-* 01:30:00
Persistent=true
RandomizedDelaySec=300

[Install]
WantedBy=timers.target

systemctl enable --now db-dump.timer, check with systemctl list-timers.

Why → Output goes to the journal, Persistent=true runs a missed job after downtime, and resource limits and OnFailure= alerts are available.

Interview tip → Validate calendar expressions with systemd-analyze calendar '*-*-* 01:30:00'.

All Linux questions Roadmap: Linux

More on Scheduling, automation and scripting