A system administrator is investigating why a `systemd` service named `mybackup.service` is not running as expected. The service is configured to run a script every day at 02:00. Upon checking `systemctl status mybackup.service`, it shows `inactive (dead)`. What is the most likely reason for this status given the description?
- AThe `mybackup.service` unit file has an `[Install]` section missing `WantedBy=multi-user.target`.
- BThe `mybackup.service` unit file has `Restart=always` configured, causing it to fail immediately.
- CThe `mybackup.timer` unit, which triggers `mybackup.service`, is not enabled or started.
- DThe `mybackup.service` is masked, preventing it from being started.
Show answer & explanationAnswer & explanation
Correct answer: C. The `mybackup.timer` unit, which triggers `mybackup.service`, is not enabled or started.
If a service is meant to be triggered by a timer and shows `inactive (dead)`, it usually means the service itself isn't started directly as a long-running daemon but is executed on demand. The most likely issue is that its corresponding timer unit (`mybackup.timer`) is not active, thus not triggering the service at the scheduled time. Services triggered by timers often appear `inactive (dead)` when not actively running.
Why the other options are wrong
- A. Missing `WantedBy=multi-user.target` would prevent the service from starting at boot *directly*, but a timer unit would still be able to activate it.
- B. `Restart=always` would cause the service to restart if it failed, not remain `inactive (dead)` unless it's in a continuous crash loop, which isn't implied by the context of a timer-triggered service.
- D. If the service were masked, `systemctl status` would explicitly show `masked` as its state, not `inactive (dead)`.
systemd Timer Unit Relationship
A `systemd` timer unit (`.timer`) is used to schedule the execution of a corresponding `systemd` service unit (`.service`). The service unit is typically configured as `Type=oneshot` and is only activated by the timer.
- `.timer` unit activates a `.service` unit.
- Timer units must be enabled and started.
- Service units often appear `inactive (dead)` when not actively running, if timer-triggered.
Memory trick: TIMERS control SERVICES, check the TIMER first!