Systemd Service timers: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 10: Zeile 10:
 
4 timers listed.
 
4 timers listed.
 
Pass --all to see loaded but inactive timers, too.
 
Pass --all to see loaded but inactive timers, too.
 +
</pre>
 +
=Monotonic timer=
 +
*Example
 +
A timer which will start 15 minutes after boot and again every week while the system is running.
 +
*cat /etc/systemd/system/foo.timer
 +
<pre>
 +
[Unit]
 +
Description=Run foo weekly and on boot
 +
 +
[Timer]
 +
OnBootSec=15min
 +
OnUnitActiveSec=1w
 +
 +
[Install]
 +
WantedBy=timers.target
 
</pre>
 
</pre>
  
 
=Links=
 
=Links=
 
*https://wiki.archlinux.org/index.php/Systemd/Timers
 
*https://wiki.archlinux.org/index.php/Systemd/Timers

Version vom 27. Oktober 2017, 07:41 Uhr

List Timers

  • systemctl list-timers
NEXT                         LEFT        LAST                         PASSED        UNIT                         ACTIVATES
n/a                          n/a         Di 2017-10-24 17:02:48 CEST  2 days ago    ureadahead-stop.timer        ureadahead-stop.service
Fr 2017-10-27 18:18:28 CEST  8h left     Fr 2017-10-27 09:14:16 CEST  24min ago     apt-daily.timer              apt-daily.service
Fr 2017-10-27 22:41:17 CEST  13h left    Mi 2017-10-25 14:51:49 CEST  1 day 18h ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Mo 2017-10-30 04:07:40 CET   2 days left Di 2017-10-24 14:36:05 CEST  2 days ago    snapd.refresh.timer          snapd.refresh.service

4 timers listed.
Pass --all to see loaded but inactive timers, too.

Monotonic timer

  • Example

A timer which will start 15 minutes after boot and again every week while the system is running.

  • cat /etc/systemd/system/foo.timer
[Unit]
Description=Run foo weekly and on boot

[Timer]
OnBootSec=15min
OnUnitActiveSec=1w 

[Install]
WantedBy=timers.target

Links