Interview Prep/Linux/Scheduling, automation and scripting

A laptop-style VM is often off at night, so the daily cleanup job never runs. How do you make sure it runs once a day anyway?

BeginnerScenarioScheduling, automation and scripting
Answer

Situation read → Machines that aren't always on need catch-up scheduling.

What I'd do →

  • Put the script in /etc/cron.daily/, which anacron runs once a day when the machine is up.
  • Or use a systemd timer with OnCalendar=daily and Persistent=true.

Why → Plain cron only runs at the exact minute; if the host is off, the run is skipped.

Interview tip → /var/spool/anacron/ holds the last-run timestamps.

All Linux questions Roadmap: Linux

More on Scheduling, automation and scripting