Systemd/timers: Difference between revisions

Klinger (talk | contribs)
Unabomberlive (talk | contribs)
Make page translatable
Line 1: Line 1:
{{Systemd/breadcrumb}}
{{Systemd/breadcrumb}}


Timers are systemd unit files whose name ends in .timer that control .service files or events. Timers can be used as an alternative to <code>cron</code>. Timers have built-in support for calendar-based events and monotonic time events, and can be run asynchronously.  
<translate>
 
Timers are systemd unit files whose name ends in .timer that control .service files or events. Timers can be used as an alternative to <code>cron</code>. Timers have built-in support for calendar-based events and monotonic time events, and can be run asynchronously.
</translate>
<translate>
== Configuration ==
== Configuration ==
 
</translate>
<translate>
The following example timer runs a systemd unit every 5 minutes which invokes a bash script.
The following example timer runs a systemd unit every 5 minutes which invokes a bash script.
 
</translate>
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
systemd.timers."hello-world" = {
systemd.timers."hello-world" = {
Line 28: Line 31:
};
};
</syntaxHighlight>
</syntaxHighlight>
 
<translate>
The following example starts once a day (at 12:00am). When activated, it triggers the service immediately if it missed the last start time (option Persistent=true), for example due to the system being powered off.
The following example starts once a day (at 12:00am). When activated, it triggers the service immediately if it missed the last start time (option Persistent=true), for example due to the system being powered off.
 
</translate>
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
...
...
Line 39: Line 42:
};
};
</syntaxHighlight>
</syntaxHighlight>
 
<translate>
More examples can be found at the [https://wiki.archlinux.org/title/Systemd/Timers Arch Wiki] and at the <code>systemd.timer</code> manpage.
More examples can be found at the [https://wiki.archlinux.org/title/Systemd/Timers Arch Wiki] and at the <code>systemd.timer</code> manpage.
 
</translate>
<translate>
== Usage ==
== Usage ==
 
</translate>
<translate>
List active timers and their current state:
List active timers and their current state:
 
</translate>
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl list-timers
systemctl list-timers
</syntaxhighlight>
</syntaxhighlight>
 
<translate>
Manually run a service once for testing purposes:
Manually run a service once for testing purposes:
 
</translate>
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl start hello-world
systemctl start hello-world
</syntaxhighlight>
</syntaxhighlight>
[[Category:systemd]]
[[Category:systemd]]