How to use cron vs systemd timers
· Category: Linux
Short answer
Cron is simple and universal; systemd timers offer better logging, dependencies, and fine-grained control.
Key differences
- Cron: Simple time-based scheduling; email output; limited dependencies.
- Systemd timers: Integrated logging via journal; can depend on other units; more complex setup.
When to use each
- Cron: Simple periodic scripts, legacy systems, quick setup.
- Systemd timers: Services needing startup dependencies, complex scheduling, or detailed logging.
Tips
- Migrate incrementally; cron jobs can call systemd services.
- Use
Persistent=truein timers to catch up on missed runs. - Both can coexist; choose based on complexity and monitoring needs.