Swap cron for systemd timers to schedule tasks with tighter integration, logging and dependency control. 16.11.2025 | reading time: 2 min systemd timers are a system-native way to schedule tasks; they tie timing to units, logging and dependencies so scheduled jobs behave like services and not like detached cron jobs. Nightly cleanup example Create a simple service and timer to run a cleanup script nightly at 02:00; first create the service unit and timer unit and then enable them so systemd manages scheduling and execution: ```[Unit] Description=Nightly cleanup [Service] Type=oneshot ExecStart=/usr/local/bin/cleanup.sh # --- timer: /etc/systemd/system/cleanup.timer --- [Unit] Description=Nightly cleanup timer [Timer] OnCalendar=*-*-* 02:00:00 Persistent=true [Install] WantedBy=timers.target``` then run the commands to reload, enable and inspect: ```bash sudo systemctl daemon-reload sudo systemctl enable --now cleanup.timer sudo systemctl status cleanup.timer # sample output ● cleanup.timer - Nightly cleanup timer Loaded: loaded (/etc/systemd/system/cleanup.timer; enabled) Active: active (waiting) since Sun 2025-11-16 02:00:00 UTC; 1 day ago Next: Mon 2025-11-17 02:00:00 UTC (in 20h) Triggers: cleanup.service ``` and verify scheduled timers with `systemctl list-timers --all` to see next runtimes and last results. Tweaks and triggers Use `OnCalendar` for calendar expressions, `OnBootSec` and `OnUnitActiveSec` for relative delays, `Persistent=true` to run missed jobs after reboot, `RandomizedDelaySec` to spread load, and `AccuracySec` to control scheduling granularity; choose system-wide timers under `/etc/systemd/system` or per-user timers under `~/.config/systemd/user` depending on whether the job must run as root or the user. Related scheduling tools systemd timers coexist with older tools: `cron` remains simple and portable, `anacron` ensures jobs run on machines that are often off, and `at` schedules one-shot tasks; pick the tool that fits availability, permission and complexity constraints. Next steps Try converting a few cron jobs to timers, experiment with `OnCalendar` expressions and `Persistent=true`, and read unit manuals to master dependencies; deepen your Linux skills and consider formal certification like CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy to turn hands-on practice into recognized competence. Join Bits & Bytes Academy First class LINUX exam preparation. scripting boot-process processes utilities backup