Systemd timers solve a very specific operations problem: scheduled jobs that fail silently, miss runs after downtime, or leave you guessing when something actually executed. If you manage Linux systems and need better logging, missed-run handling, and dependency control than cron usually gives you, systemd timers are the cleaner way to schedule recurring and one-off tasks.
Quick Answer
Systemd timers are Linux scheduling units that trigger matching .service jobs on a calendar or elapsed-time basis. They are more reliable than cron for many admin tasks because they support missed-run recovery with Persistent=true, centralized journal logging, and tighter integration with systemd dependencies. They are a strong fit for backups, cleanup jobs, renewals, and delayed maintenance.
Quick Procedure
- Create a .service unit that runs the actual command.
- Create a matching .timer unit that points to the service.
- Choose OnCalendar or a monotonic timer directive.
- Add Persistent=true if you need missed-run recovery.
- Reload systemd, then start and enable the timer.
- Verify the next run with systemctl list-timers.
- Check journal logs if the job does not behave as expected.
| What it is | A systemd scheduling mechanism that triggers a .service unit |
|---|---|
| Trigger styles | Calendar-based and monotonic elapsed-time scheduling |
| Missed-run recovery | Supported with Persistent=true as of November 2026 |
| Primary logging source | systemd journal via journalctl as of November 2026 |
| Best use cases | Backups, cleanup tasks, renewals, delayed maintenance, and recurring admin jobs |
| Main advantage over cron | Better observability and tighter integration with service management |
| Official reference | systemd.timer and systemd.service |
Introduction
Most scheduling problems start the same way: a job was supposed to run, but nobody knows whether it fired, failed, or got skipped during a reboot. That is where systemd timers matter. They turn scheduling into a managed service instead of a one-line shell command with weak visibility.
Systemd treats scheduling, logging, and dependencies as part of one control plane. That means the trigger, the executable work, and the audit trail all live in the same model, which is much easier to operate when you need to troubleshoot an outage or confirm that a maintenance job really ran.
This guide shows how to build, schedule, monitor, and maintain reliable systemd timer jobs for recurring and one-off tasks. It is written for admins who want better observability and recovery than basic cron setups, especially in environments where systems reboot, suspend, or miss windows.
Reliable scheduling is not just about when a job runs. It is about knowing what ran, why it ran, and what happened when it did not.
Note
If you are comparing scheduling options for production Linux systems, use the official systemd manuals as your source of truth. The behavior of timers can vary slightly across distributions, but the core unit model is documented in systemd.timer and systemd.service.
Understanding Systemd Timers and Service Pairs
A systemd timer is a unit that schedules execution, while the matching service unit is the file that actually runs the command. The timer does not run your script directly. It activates the service, which is why this model is cleaner than embedding a command into a single scheduler line.
This separation improves maintainability. You can test the service by hand, troubleshoot it separately, and reuse it in different ways. For example, a backup service can be triggered manually for an emergency run, by a timer for nightly execution, or by another unit after storage mounts become available.
That is a major difference from cron, where the schedule and command often live together in one line. Cron is simple, but at scale that simplicity becomes a liability because logging, dependency handling, and failure investigation tend to live somewhere else.
Calendar-based and monotonic timers
Systemd timers generally fall into two groups. Calendar-based timers use directives such as OnCalendar to run at a specific time or recurring schedule, while monotonic timers use elapsed time from a point like boot, activation, or the last successful run.
- Calendar-based example: Run a cleanup job every day at 02:15.
- Monotonic example: Run a service 15 minutes after boot.
- Recurring elapsed-time example: Run a task one hour after the last activation finishes.
Common uses include backups, log cleanup, renewal helpers, cache purges, and delayed maintenance jobs. The scheduling model is built for operations work, not just for convenience.
According to the official systemd documentation, timers are first-class units in the service manager, not a separate scheduling layer bolted onto Linux. See systemd.timer for the formal behavior.
Why Systemd Timers Often Outperform Cron
Missed-run handling is one of the biggest reasons admins move from cron to systemd timers. If a system is powered off, suspended, or rebooting when a job should have executed, a timer with Persistent=true can catch up and run the missed task after the system comes back online.
That matters in real environments. Backups, log compaction, patch verification, and certificate renewal checks are all jobs that should not disappear because a machine was offline at the wrong time. Cron usually just skips the missed window unless you build extra logic yourself.
Logging and operational visibility
Systemd routes output into the journal, so you can inspect both the service invocation and the job output with a consistent toolset. That is much easier than hunting through separate log files, local mail, or custom redirection scripts. For incident review, being able to query the exact service run is a big win.
Systemd timers also support dependency management. If a scheduled task depends on a mounted volume, a network target, or another service, systemd can model that relationship directly. That makes timers a better fit for orchestrated maintenance chains than isolated cron entries.
| Cron | Simple and familiar, but weaker on dependency control, missed-run recovery, and unified logging |
|---|---|
| Systemd timers | More operationally complete for managed Linux services, especially when reliability and auditability matter |
Cron still has a place for lightweight jobs and legacy environments. But for modern Linux administration, systemd timers usually provide stronger control and better troubleshooting signals.
How Do You Choose the Right Schedule Type?
Choose OnCalendar when you need a task to run at a specific wall-clock time, such as every night at 01:30 or on the first Monday of each month. Choose monotonic timers when the delay matters more than the clock, such as waiting 10 minutes after boot or repeating every hour after the previous run.
The practical difference is simple: calendar scheduling follows the clock, while monotonic scheduling follows elapsed time. That makes calendar timers better for business windows and reporting tasks, and monotonic timers better for startup delays, post-deployment actions, or maintenance loops that should not drift based on reboot time.
When precision matters
Precision and drift matter depending on the task. If a database optimization job should run after business hours, OnCalendar is easier to reason about. If a service should wait for the system to stabilize after startup before beginning log cleanup, OnBootSec or OnActiveSec is usually the better choice.
- Use OnCalendar for backups, reporting, compliance checks, and scheduled business tasks.
- Use OnBootSec for jobs that should start after a boot delay.
- Use OnActiveSec for a timer that begins relative to when the timer itself became active.
- Use OnUnitActiveSec when you want recurring execution after the last successful activation.
The official systemd.time documentation explains these directives in detail and is worth keeping open while you design schedules.
Prerequisites
Before you create a timer, make sure the job itself is ready. A timer is only as good as the service it triggers.
- A Linux system using systemd as the init and service manager
- Root access or the ability to manage user-level units in your own account
- A script or command that already works when run manually
- Basic familiarity with unit files and shell scripts
- A clear decision about whether the schedule should be calendar-based or monotonic
- Permission to read logs with journalctl
- Enough knowledge of file paths, environment variables, and exit codes to debug failures
Warning
Do not build the timer first and hope the script is fine. Test the underlying service command manually until it is idempotent, predictable, and safe to run more than once.
Building a Basic Timer and Service Pair
The standard pattern is straightforward: create a .service file for the work and a .timer file for the schedule. The timer references the service by name, which keeps execution logic separate from scheduling logic.
For example, if your service is called backup-report.service, your timer should typically be named backup-report.timer. That matching convention makes the pair easy to identify, and it reduces confusion when you are reviewing dozens of units on a server.
Service file first, timer file second
Start by writing the service unit and placing your command in ExecStart=. Keep the script idempotent so a catch-up run or retry does not corrupt data, duplicate records, or reprocess a job that already completed.
Then create the timer and attach it to the service. A simple recurring example could look like this:
[Unit]
Description=Nightly report generation
[Service]
Type=oneshot
ExecStart=/usr/local/bin/generate-report.sh
[Unit]
Description=Run nightly report generation
[Timer]
OnCalendar=--* 02:00:00
Persistent=true
[Install]
WantedBy=timers.target
- Write the service. Put the actual command in the service file so you can run it independently for testing.
- Add the timer. Use the timer to define when the service should be triggered.
- Choose a unit name. Keep the names aligned so the relationship is obvious during troubleshooting.
- Test manually. Run
systemctl start backup-report.servicebefore enabling the timer. - Enable and monitor. Activate the timer after the service behaves correctly on demand.
Systemd service units are documented in systemd.service. If you are designing a job that writes files, talks to databases, or calls external APIs, make sure the script handles failures cleanly and exits with a nonzero code when it cannot complete.
Configuring Common Timer Directives
OnCalendar is the most recognizable directive, but it is only part of the timer toolkit. You will also use OnBootSec, OnActiveSec, OnStartupSec, and Persistent to control how the job behaves across reboots and missed windows.
Persistent=true is especially important for recurring jobs that should not vanish just because the machine was unavailable. If a host was down during the planned execution time, systemd can run the job after restart so you do not silently lose the scheduled action.
Useful directives in practice
- OnCalendar= defines wall-clock scheduling.
- OnBootSec= waits a fixed amount of time after boot.
- OnActiveSec= runs relative to timer activation.
- OnStartupSec= runs after the manager starts.
- OnUnitActiveSec= repeats relative to the last activation of the associated unit.
- Persistent=true catches up missed runs after downtime.
- AccuracySec= allows small schedule flexibility to reduce wakeups.
- RandomizedDelaySec= spreads execution time to reduce load spikes.
These settings affect more than convenience. AccuracySec and RandomizedDelaySec can help with load distribution when many systems run the same timer at once, such as patch checks or telemetry uploads. That is useful in fleets where dozens or hundreds of hosts would otherwise stampede the same backend at the same minute.
When a timer needs to target a service with a different name, use Unit=. That gives you more flexibility in larger automation setups where one schedule might trigger more than one service pattern.
| Persistent=true | Improves reliability by running missed jobs after downtime |
|---|---|
| RandomizedDelaySec= | Improves load distribution by adding controlled randomness |
For the authoritative reference, use systemd.timer.
How Do You Enable, Start, and Manage Timers?
Enabling a timer tells systemd to start it automatically at boot or when the relevant target is reached. Starting a timer launches it immediately in the current session. Those are related actions, but they are not the same.
In operational terms, you usually do both. You reload systemd after editing the unit file, start the timer so it begins counting now, and enable it so it survives reboots. That sequence avoids the common mistake of editing a unit and assuming systemd has already noticed the change.
- Reload unit files. Run
systemctl daemon-reloadafter any unit file edit. - Start the timer. Use
systemctl start backup-report.timerto activate it now. - Enable the timer. Use
systemctl enable backup-report.timerto persist it across reboots. - Check status. Run
systemctl status backup-report.timerto confirm the active state. - Inspect the schedule. Use
systemctl list-timersto see the next and last trigger times. - Pause or remove it. Use stop, disable, or mask depending on whether you want a temporary pause or a hard block.
The systemctl list-timers output is especially useful during change windows because it shows what is due soon and what has already run. That makes it easier to confirm whether the timer is aligned with your maintenance plan.
How to Verify It Worked
The most reliable sign that a timer worked is not just that the timer shows as active, but that the matching service ran and exited successfully. You need to verify both the trigger and the execution.
Start by checking the timer status. Then inspect the service unit to make sure it actually completed. Finally, confirm the expected side effect: a file changed, a backup appeared, a report was generated, or the desired cleanup happened.
- Timer status:
systemctl status your-job.timer - Service status:
systemctl status your-job.service - Next run:
systemctl list-timers --all - Journal for the service:
journalctl -u your-job.service - Journal for the timer:
journalctl -u your-job.timer
Common failure symptoms include a timer that appears enabled but never triggers, a service that starts and immediately exits with an error, or a script that runs but does nothing because an expected environment variable is missing. A bad file path, typo in the unit name, or permission problem can look like a scheduling issue when it is really a service issue.
Pro Tip
If the timer fired but the job failed, inspect the service unit first. The timer usually did its job; the failure is often inside the script, path, or permissions used by the service.
How Do You Make Timers Reliable in Production?
Reliability comes from the whole job design, not the timer alone. A good timer attached to a fragile script still creates incidents. The script needs to be idempotent, explicit about errors, and safe to re-run after an outage or a missed window.
That means handling exit codes correctly, validating assumptions up front, and logging enough context to understand what happened. If your job works only when it runs once on a perfect schedule, it is not production-ready.
Production hardening checklist
- Make the script idempotent. Running it twice should not duplicate work.
- Fail loudly. Exit nonzero when the job cannot complete.
- Log meaningful messages. Include timestamps, object names, and failure reasons.
- Prevent overlap. Use lock files or built-in safeguards if a job can still be running when the next trigger occurs.
- Set dependencies. Wait for mounts, databases, or network prerequisites before starting.
- Review runtime length. Ensure long jobs do not collide with the next schedule.
For example, a backup job should check whether its destination is mounted before writing anything. A cleanup job should confirm that it is targeting the right directory before removing files. A report generator should verify that the database is reachable and that required credentials exist before it starts producing output.
When a scheduled task matters to operations, pair the timer with monitoring or alerting. That can be as simple as checking a success marker file or as advanced as integrating the service failure into your alert stack. The important thing is that a failed timer should not be invisible.
Advanced Scheduling Patterns and Real-World Examples
Systemd timers are useful well beyond basic nightly jobs. They are a good fit for recurring maintenance, delayed post-boot tasks, and chained workflows where one service depends on another system event.
A common example is a backup workflow. One service creates the archive, another verifies the checksum, and a timer triggers the sequence on a regular schedule. Another example is certificate renewal checks, where a timer runs a helper script that validates expiry windows and refreshes certificates only when needed.
Practical use cases
- Nightly backups: Trigger archive creation after business hours.
- Log rotation helpers: Compress or validate logs after standard rotation.
- Cache cleanup: Remove stale cache entries on a schedule.
- Temporary file pruning: Clean old scratch data from work directories.
- Database tasks: Run optimization, vacuuming, or statistics updates.
- Certificate checks: Run renewal logic before expiration windows close.
User-level timers are also worth considering. They let individual users run personal maintenance jobs, local development helpers, or per-user automation without needing a system-wide unit. That is useful on shared Linux hosts where not every scheduled task belongs in root’s unit directory.
For more advanced orchestration, one timer can trigger a service that starts another unit chain through dependencies. That pattern is especially helpful when you need a broader automation workflow with controlled ordering, rather than a single flat script that does everything itself.
What Current-Year Best Practices Should You Follow?
Modern Linux operations demand auditability, repeatability, and clear ownership. Timers should not be hidden in a user’s home directory with no documentation. They should be named clearly, tracked in version control, and reviewed like any other operational artifact.
Keep unit files under source control so changes are visible and reversible. Document the owner, purpose, schedule, dependencies, and expected output for each timer. That makes the job easier to hand off, audit, and recover after staff changes or infrastructure refreshes.
Practical operating habits
- Review stale jobs: Remove timers that no longer have a business purpose.
- Align with maintenance windows: Avoid triggering heavy work during peak usage.
- Match cloud behavior: Consider instance stop/start cycles, autoscaling, and host replacement.
- Document schedule intent: Write down why the job exists, not just when it runs.
- Use vendor docs: Recheck behavior against official systemd documentation after upgrades.
That last point matters. Unit behavior can differ by distribution version or systemd release, so the safest reference remains the official documentation for systemd.timer and systemd.service. If you need a broader operating model for reliability, the NIST Cybersecurity Framework at NIST is also useful for thinking about control, visibility, and recovery in a structured way.
Key Takeaway
- Systemd timers are a better fit than cron when you need missed-run recovery, centralized logging, and managed dependencies.
- Service units should contain the real work, while timer units should only define when the work runs.
- Persistent=true helps scheduled tasks recover after downtime or reboot.
- OnCalendar is best for wall-clock schedules, while monotonic timers are better for elapsed-time delays.
- Reliable automation comes from a good script, a well-designed service, and a correctly configured timer.
Conclusion
Systemd timers give you dependable scheduling, better visibility, and tighter integration with systemd-managed services. They are not a replacement for good scripting, but they make solid scripts far easier to operate, troubleshoot, and recover.
If your environment still relies on cron for important jobs, audit the tasks that benefit most from missed-run handling, centralized logging, and dependency awareness. Backups, cleanup routines, renewal checks, and delayed maintenance jobs are the first candidates to move.
The practical takeaway is simple: reliable automation comes from combining a stable script with a correctly designed timer and service pair. If you build that foundation carefully, systemd timers will do exactly what operations teams need them to do: run when they should, tell you what happened, and recover when the system was unavailable.
Systemd and Linux are trademarks of their respective owners.
