LinuxCommandLibrary

systemctl-list-timers

List active systemd timers

TLDR

List all active timers

$ systemctl list-timers
copy

List all timers, including inactive ones
$ systemctl list-timers [[-a|--all]]
copy

List timers matching a pattern
$ systemctl list-timers [pattern]
copy

List timers matching a specific state
$ systemctl list-timers --state [active|inactive|failed|...]
copy

SYNOPSIS

systemctl list-timers [OPTIONS]

PARAMETERS

-a, --all
    Shows all loaded timer units, whether they are currently active, inactive, enabled, or disabled. By default, only active timers are displayed.

--no-pager
    Suppresses the use of a pager for the output, printing the entire content directly to the standard output.

--plain
    Outputs a plain-text table without graphical elements or truncation. This format is particularly useful for scripting or parsing the output programmatically.

--full
    Displays full unit names without truncation. By default, long unit names might be ellipsized to fit the terminal width.

--value
    When used in conjunction with --plain, this option only prints the values of the output table, omitting column headers and unit names. Ideal for extracting specific data points.

--output=FORMAT
    Specifies the output format. Common formats include json, json-pretty, yaml, json-sse, and plain, allowing for machine-readable or human-readable structured output.

--output-config
    Shows the unit configuration as a table, which can be useful for debugging or reviewing timer settings.

--output-pager[=BOOL]
    Controls whether to pipe output to a pager when machine-readable formats like --output=json are used. Default is no.

--output-truncated-columns=no
    Prevents truncation of column content in the output, ensuring all data is fully visible.

--output-abbreviate-columns=no
    Prevents abbreviation of column headers in the output, showing the full header names.

DESCRIPTION

The systemctl list-timers command is a powerful utility within the systemd ecosystem used to display detailed information about active and loaded timer units. Timer units are systemd's modern and flexible alternative to traditional cron jobs, enabling the execution of services at specific times or intervals. This command provides a comprehensive overview, including when each timer last ran, when it's scheduled to run next, and the associated service unit it activates. It's an indispensable tool for system administrators to manage, monitor, and troubleshoot scheduled tasks, ensuring system maintenance and automated operations run as expected. By default, it shows active timers, but various options allow for viewing all loaded timers regardless of their state, customizing the output format for scripting, and displaying full unit names without truncation, making it highly adaptable to different use cases.

CAVEATS

  • Traditional Cron Jobs Not Shown: systemctl list-timers only displays timers managed by systemd. Traditional cron jobs configured via crontab -e or files in /etc/cron.* will not appear in this output.
  • 'NEXT' Time for One-Shot Timers: If a timer is configured to run only once and has already executed, the 'NEXT' column might not show a future time until the timer is explicitly reactivated or reloaded.
  • Event-Based Timers: Timers relying on specific system events (e.g., OnBoot) might not show a clear 'NEXT' time in the same predictable manner as interval-based timers (e.g., OnCalendar, OnActiveSec).

UNDERSTANDING TIMER OUTPUT COLUMNS

The default output of systemctl list-timers presents several key columns that provide a quick overview of timer states:

NEXT: The next scheduled time the timer is set to activate its associated service.
LEFT: The remaining time duration until the next scheduled activation.
LAST: The last time the timer successfully activated its associated service.
PASSED: The time duration that has elapsed since the last activation.
UNIT: The name of the timer unit itself (e.g., mybackup.timer).
ACTIVATES: The name of the service unit that this timer is configured to activate (e.g., mybackup.service).

This structured output is vital for quickly assessing the operational status and schedule of all systemd timers.

CREATING AND MANAGING TIMER UNITS

To implement a custom scheduled task using systemd timers, you typically create two unit files: a service unit (e.g., /etc/systemd/system/mytask.service) which defines what command or script to execute, and a corresponding timer unit (e.g., /etc/systemd/system/mytask.timer) which specifies when the service should run. The timer unit uses directives like OnCalendar= for specific dates/times or OnUnitActiveSec= for interval-based scheduling.

After creating or modifying these unit files, you must run sudo systemctl daemon-reload to make systemd aware of the changes. Then, to enable and start the timer, use sudo systemctl enable --now mytask.timer. This command ensures the timer starts immediately and persists across reboots.

HISTORY

The systemctl list-timers command emerged as an essential component of the systemd init system, which gained prominence in the early 2010s as the default init system for many major Linux distributions. As systemd introduced its sophisticated timer unit functionality as a modern alternative to traditional cron, the list-timers subcommand was developed to provide administrators with a native, integrated method to inspect and manage these scheduled tasks. Its design reflects systemd's broader philosophy of unified service management, detailed status reporting, and robust scheduling capabilities, seamlessly integrating timers into the overall system administration workflow.

SEE ALSO

systemctl(1), systemd.timer(5), systemd.service(5), journalctl(1), cron(8), crontab(1)

Copied to clipboard