Linux Cron and Timer Persistence
Cron jobs and systemd timers are the most reliable persistence mechanisms on Linux. They survive reboots, run without an active user session, and blend in with dozens of legitimate scheduled tasks already present on every system. Root-level cron entries execute regardless of who is logged in.
System-wide cron jobs
Entries in /etc/cron* directories and /etc/crontab run as root by default. These require root access to create but persist across reboots and user password changes.
Name the file something that blends with existing entries — check /etc/cron.d/ for existing filenames and match the naming pattern. Entries in cron.d must include the username field (between timing and command), unlike user crontabs.
User crontabs
User crontabs do not require root and run as the user who created them. Less reliable for root-level persistence but useful when you only have a low-privilege shell and need the session to survive reconnection.
Systemd timers
Systemd timers are the modern replacement for cron. They are harder to spot with a simple crontab listing and support more trigger types — on boot, on calendar, on network availability, and more. Creating a timer requires two unit files: a service unit and a timer unit.
Cleaning up
Was this helpful?
Your feedback helps improve this page.