Systemd Service timers: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 12: Zeile 12:
 
</pre>
 
</pre>
 
=Monotonic timer=
 
=Monotonic timer=
*Example
+
Example
 +
 
 
A timer which will start 15 minutes after boot and again every week while the system is running.  
 
A timer which will start 15 minutes after boot and again every week while the system is running.  
 
*cat /etc/systemd/system/foo.timer
 
*cat /etc/systemd/system/foo.timer

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