Systemd/Timers: Unterschied zwischen den Versionen

Aus wiki.archlinux.de
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 36: Zeile 36:


Dieses Beispiel stellt eine Minimalvariante der Dateien dar. Weitere Optionen siehe [[Systemd/Timers#Details]].
Dieses Beispiel stellt eine Minimalvariante der Dateien dar. Weitere Optionen siehe [[Systemd/Timers#Details]].
Als [Service] kann ein Befehl oder ein ausführbares Script genutzt werden.
Als [Service] kann ein Befehl oder ein ausführbares Script genutzt werden.
Service- und Timerdatei werden mit root Rechten in /etc/systemd/system/ abgelegt und müssen vor dem . (Punkt) den gleichen Namen tragen.
Service- und Timerdatei werden mit root Rechten in /etc/systemd/system/ abgelegt und müssen vor dem . (Punkt) den gleichen Namen tragen.


Zeile 42: Zeile 44:
  systemctl enable --now beispiel.timer
  systemctl enable --now beispiel.timer
(Bei der ersten Initialisierung legt das System automatisch einen symlink /etc/systemd/system/basic.target.wants/ → /etc/systemd/system/ der {{ic|.timer}} Datei an.)
(Bei der ersten Initialisierung legt das System automatisch einen symlink /etc/systemd/system/basic.target.wants/ → /etc/systemd/system/ der {{ic|.timer}} Datei an.)
Mit ''enable --now'' startet der Timer unverzüglich und permanent, sodass er auch nach einem Neustart aktiv ist.
Mit ''enable --now'' startet der Timer unverzüglich und permanent, sodass er auch nach einem Neustart aktiv ist.
Ohne ''--now'' werden ''enable oder disable'' erst nach einem reboot wirksam.
Ohne ''--now'' werden ''enable oder disable'' erst nach einem reboot wirksam.
Ein ''start oder stop'' wirkt sich hingegen nur auf die laufende Sitzung aus.
 
Ein ''start oder stop'' wirkt sich nur auf die laufende Sitzung aus.


  systemctl reenable --now beispiel.timer
  systemctl reenable --now beispiel.timer
Zeile 59: Zeile 64:
  journalctl -xe
  journalctl -xe


== Details ==
== Optionen ==
Nun zu den Optionen innerhalb der {{ic|.timer}} und {{ic|.service}} Dateien und welche Angaben hier getätigt werden können.
Die folgende Auflistung der einzelnen Optionen innerhalb der Sektionen der {{ic|.timer}} und {{ic|.service}} Dateien will lediglich einen Überblick bieten.
Nur die '''fettgedruckten Optionen sind Pflicht'''.


=== [Unit] ===
Für Details wird auf die jeweilige ''man page'' verwiesen.
* '''Description=''' #Hier muss die Einheit benannt werden.
 
Nur die '''fettgedruckten Optionen sind Pflichtangaben ''' der betreffenden Sektion.
 
=== [Unit] Sektion ===
* '''Description=''' #Hier muss die Einheit beschrieben werden. Die Formulierung ist frei. Auch darf sie in der {{ic|.timer}} und {{ic|.service}} Datei unterschiedlich sein. Kurze, aussagefähige Beschreibungen sind hierbei vorzuziehen.
* Documentation= #Eine URL kann hier angegeben werden.
* Documentation= #Eine URL kann hier angegeben werden.
* Requires=, Requisite= #Weitere Units können hier angegeben werden.
* Requires=, Requisite= #Weitere Units können hier angegeben werden.
Zeile 90: Zeile 98:
* SourcePath= # Überprüft das Vorhandensein einer Datei.  
* SourcePath= # Überprüft das Vorhandensein einer Datei.  
   
   
Die Auflistung der Optionen kann lediglich dem ersten Überblick dienen. Genauere Auskunft gibt: {{ic|man systemd.unit}}
Genauere Auskunft gibt: {{ic|man systemd.unit}}


=== [Timer] ===  
=== [Timer] Sektion ===  
Es können hier mehrere Zeitangaben gemacht werden. Mindestens '''eine Zeitangabe muss''' es in [Timer] geben.
Es können hier mehrere Zeitangaben gemacht werden. Mindestens '''eine Zeitangabe muss''' es in [Timer] geben.


==== relative Zeitangaben ====
==== Relative Zeitangaben ====
Sind abhängig von anderen Ereignissen
Sind abhängig von anderen Ereignissen
* OnActiveSec= #Zeitspanne seit Aktivierung des Timers selbst
* OnActiveSec= #Zeitspanne seit Aktivierung des Timers selbst
Zeile 113: Zeile 121:
  months, month, M (definiert als 30.44 Tage)
  months, month, M (definiert als 30.44 Tage)
  years, year, y (definiert als 365.25 Tage)
  years, year, y (definiert als 365.25 Tage)
 
Ohne Verwendung einer Einheit werden alle Angaben als Sekunden gewertet.


Beispiel:
Beispiel:
  OnBootSec=2d 1h 30m
  OnBootSec=2d 1h 30m
siehe auch ''man systemd.time''
Ohne Verwendung einer Einheit werden alle Angaben als Sekunden gewertet.


==== absolute Zeitangaben ====
 
==== Absolute Zeitangaben ====
* OnCalendar=  #absolute Zeitangabe
* OnCalendar=  #absolute Zeitangabe


Zeile 130: Zeile 137:
Die Angabe eines Wochentags erfolgt in Englisch. Sie ist optional.
Die Angabe eines Wochentags erfolgt in Englisch. Sie ist optional.
Jede Rubrik kann mit "," oder ".." versehen werden oder durch "*" ersetzt werden.
Jede Rubrik kann mit "," oder ".." versehen werden oder durch "*" ersetzt werden.
Weiteres dazu siehe {{ct|man systemd.time}}.


==== Weitere Optionen in [Timer] ====
==== Weitere Optionen in [Timer] ====
Zeile 141: Zeile 146:
* RemainAfterElapse=true/false #true hält den Timer aktiv, false beendet den Timer nach einmaliger Ausführung.
* RemainAfterElapse=true/false #true hält den Timer aktiv, false beendet den Timer nach einmaliger Ausführung.


=== [Install] ===
Weiteres dazu siehe {{ic|man systemd.time}}.
* WantedBy=basic.target
 
=== [Install] Sektion ===
* Alias= #Aliasnamen der Unit. Wird nicht von jedem Type unterstützt.
* '''WantedBy=''', RequiredBy= basic.target #Legt einen symbolischen Link nach .wants/ bzw. .requires/ bei Initialisierung der Unit. Bei Angabe weiterer Units erhalten,in Zusammenhang mit Wants= and Requires= der [Unit] Sektion weitere Units einen Symlink.
* Also= #installiert oder deinstalliert andere Units bei Aktivierung dieser Unit.
* DefaultInstance= #Regelt den expliziten Einsatz von Vorlage Unit Dateien.
 
Näheres dazu siehe {{ic|man systemd.unit}}.
 
   
=== [Service] ===
* Type=simple, forking, oneshot, dbus, notify, idle #default ist simple.
* RemainAfterExit= #Default ist no. yes hält den service aktiv.
* GuessMainPID= #Default ist yes. Wenn die PID nicht exakt bestimmt werden kann wird normalerweise versucht sie zu berechnen. Dies kann hier ausgeschaltet werden.
* PIDFile= #In Zusammenhang mit Type=forking kann für den Fork eine PID hinterlegt werden.
* BusName= #Bei Type=dbus kann hier der betreffende D-bus Name vereinbart werden.
* '''ExecStart=''' Angabe von einem oder mehrerer Befehle und deren Argumente oder eines ausführbaren Scripts. Die absolute Pfadangabe wird verlangt.
* ExecStartPre=, ExecStartPost= #Hier aufgeführte Befehle werden vor bzw. nach ExecStart= ausgeführt.
* ExecReload=# Wind genutzt um eine Rekonfiguration des Service zu veranlassen.
* ExecStop= #Wird benötigt falls der Service zum Beenden spezielle Befehle braucht.
* ExecStopPost= #Ergänzt ExecStop=
* RestartSec= #wird nur für Restart= gebraucht.
*
*
*
*
*
*
=== [Service] ===
 
* Type=oneshot
 
* Nice=19
* Nice=19
* IOSchedulingClass=2
* IOSchedulingClass=2
* IOSchedulingPriority=7
* IOSchedulingPriority=7
* Environment="ABRT_IGNORE_PYTHON=1"
* Environment="ABRT_IGNORE_PYTHON=1"
* '''ExecStart=''' Angabe eines Befehls oder eines ausführbaren Scripts.
* Type=simple
* ExecStart=/usr/bin/pacman -Syuq --noconfirm
* TimeoutStopSec=180
* TimeoutStopSec=180
* KillMode=process
* KillMode=process
* KillSignal=SIGINT
* KillSignal=SIGINT
     
      RestartSec=
          Configures the time to sleep before restarting a service (as
          configured with Restart=). Takes a unit-less value in seconds, or a
          time span value such as "5min 20s". Defaults to 100ms.
      TimeoutStartSec=
          Configures the time to wait for start-up. If a daemon service does
          not signal start-up completion within the configured time, the
          service will be considered failed and will be shut down again.
          Takes a unit-less value in seconds, or a time span value such as
          "5min 20s". Pass "infinity" to disable the timeout logic. Defaults
          to DefaultTimeoutStartSec= from the manager configuration file,
          except when Type=oneshot is used, in which case the timeout is
          disabled by default (see systemd-system.conf(5)).
      TimeoutStopSec=
          Configures the time to wait for stop. If a service is asked to
          stop, but does not terminate in the specified time, it will be
          terminated forcibly via SIGTERM, and after another timeout of equal
          duration with SIGKILL (see KillMode= in systemd.kill(5)). Takes a
          unit-less value in seconds, or a time span value such as "5min
          20s". Pass "infinity" to disable the timeout logic. Defaults to
          DefaultTimeoutStopSec= from the manager configuration file (see
          systemd-system.conf(5)).
      TimeoutSec=
          A shorthand for configuring both TimeoutStartSec= and
          TimeoutStopSec= to the specified value.
      RuntimeMaxSec=
          Configures a maximum time for the service to run. If this is used
          and the service has been active for longer than the specified time
          it is terminated and put into a failure state. Note that this
          setting does not have any effect on Type=oneshot services, as they
          terminate immediately after activation completed. Pass "infinity"
          (the default) to configure no runtime limit.
      WatchdogSec=
          Configures the watchdog timeout for a service. The watchdog is
          activated when the start-up is completed. The service must call
          sd_notify(3) regularly with "WATCHDOG=1" (i.e. the "keep-alive
          ping"). If the time between two such calls is larger than the
          configured time, then the service is placed in a failed state and
          it will be terminated with SIGABRT. By setting Restart= to
          on-failure, on-watchdog, on-abnormal or always, the service will be
          automatically restarted. The time configured here will be passed to
          the executed service process in the WATCHDOG_USEC= environment
          variable. This allows daemons to automatically enable the
          keep-alive pinging logic if watchdog support is enabled for the
          service. If this option is used, NotifyAccess= (see below) should
          be set to open access to the notification socket provided by
          systemd. If NotifyAccess= is not set, it will be implicitly set to
          main. Defaults to 0, which disables this feature. The service can
          check whether the service manager expects watchdog keep-alive
          notifications. See sd_watchdog_enabled(3) for details.
          sd_event_set_watchdog(3) may be used to enable automatic watchdog
          notification support.
      Restart=
          Configures whether the service shall be restarted when the service
          process exits, is killed, or a timeout is reached. The service
          process may be the main service process, but it may also be one of
          the processes specified with ExecStartPre=, ExecStartPost=,
          ExecStop=, ExecStopPost=, or ExecReload=. When the death of the
          process is a result of systemd operation (e.g. service stop or
          restart), the service will not be restarted. Timeouts include
          missing the watchdog "keep-alive ping" deadline and a service
          start, reload, and stop operation timeouts.
          Takes one of no, on-success, on-failure, on-abnormal, on-watchdog,
          on-abort, or always. If set to no (the default), the service will
          not be restarted. If set to on-success, it will be restarted only
          when the service process exits cleanly. In this context, a clean
          exit means an exit code of 0, or one of the signals SIGHUP, SIGINT,
          SIGTERM or SIGPIPE, and additionally, exit statuses and signals
          specified in SuccessExitStatus=. If set to on-failure, the service
          will be restarted when the process exits with a non-zero exit code,
          is terminated by a signal (including on core dump, but excluding
          the aforementioned four signals), when an operation (such as
          service reload) times out, and when the configured watchdog timeout
          is triggered. If set to on-abnormal, the service will be restarted
          when the process is terminated by a signal (including on core dump,
          excluding the aforementioned four signals), when an operation times
          out, or when the watchdog timeout is triggered. If set to on-abort,
          the service will be restarted only if the service process exits due
          to an uncaught signal not specified as a clean exit status. If set
          to on-watchdog, the service will be restarted only if the watchdog
          timeout for the service expires. If set to always, the service will
          be restarted regardless of whether it exited cleanly or not, got
          terminated abnormally by a signal, or hit a timeout.
== E-Mail ==
== E-Mail ==
[[en:Systemd/Timers]] Die engliche Wiki Seite berichtet darüber.
[[en:Systemd/Timers]] Die engliche Archwiki Seite berichtet ausführlich darüber.


== Weblinks ==
== Weblinks ==
* [https://kofler.info/systemd-timer-als-cron-alternative/ Michael Kofler Blog] Anleitung und Beispiel
* [https://kofler.info/systemd-timer-als-cron-alternative/ Michael Kofler Blog] Anleitung und Beispiel
* [https://www.techrapid.co.uk/linux/arch-linux/automatic-update-arch-linux-with-systemd Techrapid] Autoupdate #Nur bedingt zu empfehlen!
* [http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.unit&ampsect=5 man page systemd.unit] - [Unit] configuration
* [http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.unit&ampsect=5 man page systemd.unit] - [Unit] configuration
* [http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.timer&ampsect=5 Man Page] systemd.timer - [Timer] configuration
* [http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.timer&ampsect=5 Man Page] systemd.timer - [Timer] configuration
*
* [http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.service&ampsect=5 Man Pge] systemd.service - [Service] configuration
* [http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.time&ampsect=7 Man Page] systemd.time - Time and date specifications
* [http://www.dsm.fordham.edu/cgi-bin/man-cgi.pl?topic=systemd.time&ampsect=7 Man Page] systemd.time - Time and date specifications
* [https://fedoraproject.org/wiki/Features/SystemdCalendarTimers Fedora Project wiki page] on ''systemd'' calendar timers
* [https://fedoraproject.org/wiki/Features/SystemdCalendarTimers Fedora Project wiki page] on ''systemd'' calendar timers
* [https://wiki.gentoo.org/wiki/Systemd#Timer_services Gentoo wiki section] on ''systemd'' timer services
* [https://wiki.gentoo.org/wiki/Systemd#Timer_services Gentoo wiki section] on ''systemd'' timer services
* [https://www.freedesktop.org/software/systemd/man/systemd.timer.html freedesktop.org]Man page timer
* [https://www.freedesktop.org/software/systemd/man/systemd.timer.html freedesktop.org]Man page timer

Version vom 23. März 2017, 17:54 Uhr

„Systemd/Timers“ wurde von Tuxnix (Diskussion) als in Bearbeitung markiert. Um Bearbeitungskonflikte zu vermeiden, kontaktiere Tuxnix (Diskussion) bitte, bevor du den Artikel bearbeitest.



Timer bieten die Möglichkeit Aufgaben zeitlich zu steuern. Die Timer-Unit besteht aus einer .timer Datei die eine .service Datei ansteuert. Timer unterstehen systemd und müssen mit dem systemctl Befehl aktiviert werden. Eine Alternative hierzu bietet cron.

Beispiel

Die .timer Datei

# Datei /etc/systemd/system/beispiel.timer

[Unit]
Description=Beispielaktion 2Tage1St30Min nach dem Booten

[Timer]
OnBootSec=2d 1h 30m

[Install]
WantedBy=basic.target

Die .service Datei

# Datei /etc/systemd/system/beispiel.service

[Unit]
Description=Beispiel Service

[Service]
ExecStart=/home/user/beispiel.sh

Dieses Beispiel stellt eine Minimalvariante der Dateien dar. Weitere Optionen siehe Systemd/Timers#Details.

Als [Service] kann ein Befehl oder ein ausführbares Script genutzt werden.

Service- und Timerdatei werden mit root Rechten in /etc/systemd/system/ abgelegt und müssen vor dem . (Punkt) den gleichen Namen tragen.

De-/Aktivierung

systemctl enable --now beispiel.timer

(Bei der ersten Initialisierung legt das System automatisch einen symlink /etc/systemd/system/basic.target.wants/ → /etc/systemd/system/ der .timer Datei an.)

Mit enable --now startet der Timer unverzüglich und permanent, sodass er auch nach einem Neustart aktiv ist.

Ohne --now werden enable oder disable erst nach einem reboot wirksam.

Ein start oder stop wirkt sich nur auf die laufende Sitzung aus.

systemctl reenable --now beispiel.timer

Genügt damit eine nachträgliche Veränderung der Timer-Unit sofort wirksam wird.

Management

systemctl list-timers --all

Listet alle Timer auf. Sollen nur die aktiven Timer angezeigt werden genügt ein systemctl list-timers.


Die folgenden Befehle können beim Debuggen helfen:

systemctl status beispiel.timer
journalctl -xe

Optionen

Die folgende Auflistung der einzelnen Optionen innerhalb der Sektionen der .timer und .service Dateien will lediglich einen Überblick bieten.

Für Details wird auf die jeweilige man page verwiesen.

Nur die fettgedruckten Optionen sind Pflichtangaben der betreffenden Sektion.

[Unit] Sektion

  • Description= #Hier muss die Einheit beschrieben werden. Die Formulierung ist frei. Auch darf sie in der .timer und .service Datei unterschiedlich sein. Kurze, aussagefähige Beschreibungen sind hierbei vorzuziehen.
  • Documentation= #Eine URL kann hier angegeben werden.
  • Requires=, Requisite= #Weitere Units können hier angegeben werden.
  • Wants= #ein etwas weicheres Requires=
  • BindsTo= #Auch hier wird eine Unit angegeben. Fällt der service aus, weil z.B. ein device entfernt wurde, wird die Timer-Unit an der Ausführung gehindert.
  • PartOf= #beim Ausfall eines service stopp die timer-unit. Jedoch ohne Auswirkungen auf die hier aufgeführten services.
  • Conflicts=
  • Before=, After= #legt die Start Reihenfolge von services fest.
  • OnFailure= #Ersatz-Units die bei Ausfall genutzt werden sollen.
  • PropagatesReloadTo=, ReloadPropagatedFrom= #ähndelt OnFailure=
  • JoinsNamespaceOf= #Nur wichtig wenn PrivateNetwork= oder PrivateTmp= eingesetzt wird.
  • RequiresMountsFor= #Überprüft ob devices auch gemountet sind.
  • OnFailureJobMode=fail, replace, replace-irreversibly, isolate, flush, ignore-dependencies, ignore-requirements #legt das Verhalten für OnFailure= fest. Default ist replace.
  • IgnoreOnIsolate=true/false #default ist false. Bei true wird nicht mehr gestoppt bei Isolierung einer anderen Unit.
  • StopWhenUnneeded=true/false #default ist false. Steht im Zusammenhang mit Requires=. Bei true werden nicht mehr benötigte units deaktiviert.
  • RefuseManualStart=true/false, RefuseManualStop=true/false #default ist false. Ein Sicherheitstool. bei true wird die die explizite User Eingabe verlangt, bevor Units de/aktiviert werden können.
  • AllowIsolate=true/false #default ist false. Sinnvoll um ähnlich der runlevels in SysV init Systemen um unbestimmte Systemzustände zu vermeiden.
  • DefaultDependencies=true/false #Default ist true und stellt sicher, das das System komplett hochgelaufen ist bevor die timer-unit gestartet wird.
  • JobTimeoutSec=, JobTimeoutAction=, JobTimeoutRebootArgument= #stellt bei gestaffelten Jobs ein time-out zur Verfügung.
  • StartLimitIntervalSec=, StartLimitBurst= #Als default werden 5 Ausführungen eines service innerhalb von 10 Sekunden zugestanden. Dieses Limit kann hier den speziellen Anforderungen angepasst werden.
  • StartLimitAction= #Ein Ersatzservice kann bestimmt werden falls das vereinbarte StartLimitIntervalSec=, StartLimitBurst= überschritten wird.
  • RebootArgument= #Optionales reboot.
  • ConditionArchitecture=, ConditionVirtualization=, ConditionHost=, ConditionKernelCommandLine=, ConditionSecurity=, ConditionCapability=, ConditionACPower=, ConditionNeedsUpdate=, ConditionFirstBoot=, ConditionPathExists=, ConditionPathExistsGlob=, ConditionPathIsDirectory=, ConditionPathIsSymbolicLink=, ConditionPathIsMountPoint=, ConditionPathIsReadWrite=, ConditionDirectoryNotEmpty=, ConditionFileNotEmpty=, ConditionFileIsExecutable= # Vorbedingung für die Ausführung der Unit.
  • AssertArchitecture=, AssertVirtualization=, AssertHost=, AssertKernelCommandLine=, AssertSecurity=, AssertCapability=, AssertACPower=, AssertNeedsUpdate=, AssertFirstBoot=, AssertPathExists=, AssertPathExistsGlob=, AssertPathIsDirectory=, AssertPathIsSymbolicLink=, AssertPathIsMountPoint=, AssertPathIsReadWrite=, AssertDirectoryNotEmpty=, AssertFileNotEmpty=, AssertFileIsExecutable= # Wie Condition...allerdings incl. logged loudly bei failure.
  • SourcePath= # Überprüft das Vorhandensein einer Datei.

Genauere Auskunft gibt: man systemd.unit

[Timer] Sektion

Es können hier mehrere Zeitangaben gemacht werden. Mindestens eine Zeitangabe muss es in [Timer] geben.

Relative Zeitangaben

Sind abhängig von anderen Ereignissen

  • OnActiveSec= #Zeitspanne seit Aktivierung des Timers selbst
  • OnBootSec= #Zeitspanne seit dem Booten des Rechners
  • OnStartupSec= #Zeitspanne seit dem ersten Start von systemd
  • OnUnitActiveSec= #Zeitspanne seit dem letzten Start des Timers
  • OnUnitInactiveSec= #Zeitspanne seit Inaktivität der Timer-Unit

Folgende Einheiten können für relative Zeitangaben gewählt werden:

usec, us
msec, ms
seconds, second, sec, s
minutes, minute, min, m
hours, hour, hr, h
days, day, d
weeks, week, w
months, month, M (definiert als 30.44 Tage)
years, year, y (definiert als 365.25 Tage)

Ohne Verwendung einer Einheit werden alle Angaben als Sekunden gewertet.

Beispiel:

OnBootSec=2d 1h 30m


Absolute Zeitangaben

  • OnCalendar= #absolute Zeitangabe

Die absolute Zeitangabe hat folgende Syntax:

Thu,Fri 2012-*-1..5 11:12:13

Das obige Beispiel besagt: Um 11:12:13 Uhr, zwischen einschl. dem 1. und 5. Tag, aller Monate, des Jahres 2012, jedoch ausschließlich nur an Donnerstagen und Freitagen.

Die Angabe eines Wochentags erfolgt in Englisch. Sie ist optional. Jede Rubrik kann mit "," oder ".." versehen werden oder durch "*" ersetzt werden.

Weitere Optionen in [Timer]

  • AccuracySec= #Die Zeitspanne zum Ausführen beträgt als default 1 Minute. Durch Verwendung von AccuracySec kann diese Zeitspannen variiert werden.
  • RandomizedDelaySec= #Kann verwendet werden damit nicht mehrere Timer exakt zur gleichen Zeit loslegen. default ist 0.
  • Unit= #Als default ist dieser Wert identisch mit dem Suffix der .timer Datei. Bei der Verwendung von Unit= muss auch eine Datei mit selbigen Namen erstellt werden. Eine Verschachtelung von Units ist hierdurch möglich. Siehe Higgsboson Blog Reflector
  • Persistent=true #bewirkt, dass ein versäumter Job beim nächsten Rechnerstart unverzüglich nachgeholt wird.
  • WakeSystem= #Weckt das System aus dem supend mode.
  • RemainAfterElapse=true/false #true hält den Timer aktiv, false beendet den Timer nach einmaliger Ausführung.

Weiteres dazu siehe man systemd.time.

[Install] Sektion

  • Alias= #Aliasnamen der Unit. Wird nicht von jedem Type unterstützt.
  • WantedBy=, RequiredBy= basic.target #Legt einen symbolischen Link nach .wants/ bzw. .requires/ bei Initialisierung der Unit. Bei Angabe weiterer Units erhalten,in Zusammenhang mit Wants= and Requires= der [Unit] Sektion weitere Units einen Symlink.
  • Also= #installiert oder deinstalliert andere Units bei Aktivierung dieser Unit.
  • DefaultInstance= #Regelt den expliziten Einsatz von Vorlage Unit Dateien.

Näheres dazu siehe man systemd.unit.


[Service]

  • Type=simple, forking, oneshot, dbus, notify, idle #default ist simple.
  • RemainAfterExit= #Default ist no. yes hält den service aktiv.
  • GuessMainPID= #Default ist yes. Wenn die PID nicht exakt bestimmt werden kann wird normalerweise versucht sie zu berechnen. Dies kann hier ausgeschaltet werden.
  • PIDFile= #In Zusammenhang mit Type=forking kann für den Fork eine PID hinterlegt werden.
  • BusName= #Bei Type=dbus kann hier der betreffende D-bus Name vereinbart werden.
  • ExecStart= Angabe von einem oder mehrerer Befehle und deren Argumente oder eines ausführbaren Scripts. Die absolute Pfadangabe wird verlangt.
  • ExecStartPre=, ExecStartPost= #Hier aufgeführte Befehle werden vor bzw. nach ExecStart= ausgeführt.
  • ExecReload=# Wind genutzt um eine Rekonfiguration des Service zu veranlassen.
  • ExecStop= #Wird benötigt falls der Service zum Beenden spezielle Befehle braucht.
  • ExecStopPost= #Ergänzt ExecStop=
  • RestartSec= #wird nur für Restart= gebraucht.


  • Nice=19
  • IOSchedulingClass=2
  • IOSchedulingPriority=7
  • Environment="ABRT_IGNORE_PYTHON=1"
  • TimeoutStopSec=180
  • KillMode=process
  • KillSignal=SIGINT


      RestartSec=
          Configures the time to sleep before restarting a service (as
          configured with Restart=). Takes a unit-less value in seconds, or a
          time span value such as "5min 20s". Defaults to 100ms.
      TimeoutStartSec=
          Configures the time to wait for start-up. If a daemon service does
          not signal start-up completion within the configured time, the
          service will be considered failed and will be shut down again.
          Takes a unit-less value in seconds, or a time span value such as
          "5min 20s". Pass "infinity" to disable the timeout logic. Defaults
          to DefaultTimeoutStartSec= from the manager configuration file,
          except when Type=oneshot is used, in which case the timeout is
          disabled by default (see systemd-system.conf(5)).
      TimeoutStopSec=
          Configures the time to wait for stop. If a service is asked to
          stop, but does not terminate in the specified time, it will be
          terminated forcibly via SIGTERM, and after another timeout of equal
          duration with SIGKILL (see KillMode= in systemd.kill(5)). Takes a
          unit-less value in seconds, or a time span value such as "5min
          20s". Pass "infinity" to disable the timeout logic. Defaults to
          DefaultTimeoutStopSec= from the manager configuration file (see
          systemd-system.conf(5)).
      TimeoutSec=
          A shorthand for configuring both TimeoutStartSec= and
          TimeoutStopSec= to the specified value.
      RuntimeMaxSec=
          Configures a maximum time for the service to run. If this is used
          and the service has been active for longer than the specified time
          it is terminated and put into a failure state. Note that this
          setting does not have any effect on Type=oneshot services, as they
          terminate immediately after activation completed. Pass "infinity"
          (the default) to configure no runtime limit.
      WatchdogSec=
          Configures the watchdog timeout for a service. The watchdog is
          activated when the start-up is completed. The service must call
          sd_notify(3) regularly with "WATCHDOG=1" (i.e. the "keep-alive
          ping"). If the time between two such calls is larger than the
          configured time, then the service is placed in a failed state and
          it will be terminated with SIGABRT. By setting Restart= to
          on-failure, on-watchdog, on-abnormal or always, the service will be
          automatically restarted. The time configured here will be passed to
          the executed service process in the WATCHDOG_USEC= environment
          variable. This allows daemons to automatically enable the
          keep-alive pinging logic if watchdog support is enabled for the
          service. If this option is used, NotifyAccess= (see below) should
          be set to open access to the notification socket provided by
          systemd. If NotifyAccess= is not set, it will be implicitly set to
          main. Defaults to 0, which disables this feature. The service can
          check whether the service manager expects watchdog keep-alive
          notifications. See sd_watchdog_enabled(3) for details.
          sd_event_set_watchdog(3) may be used to enable automatic watchdog
          notification support.
      Restart=
          Configures whether the service shall be restarted when the service
          process exits, is killed, or a timeout is reached. The service
          process may be the main service process, but it may also be one of
          the processes specified with ExecStartPre=, ExecStartPost=,
          ExecStop=, ExecStopPost=, or ExecReload=. When the death of the
          process is a result of systemd operation (e.g. service stop or
          restart), the service will not be restarted. Timeouts include
          missing the watchdog "keep-alive ping" deadline and a service
          start, reload, and stop operation timeouts.
          Takes one of no, on-success, on-failure, on-abnormal, on-watchdog,
          on-abort, or always. If set to no (the default), the service will
          not be restarted. If set to on-success, it will be restarted only
          when the service process exits cleanly. In this context, a clean
          exit means an exit code of 0, or one of the signals SIGHUP, SIGINT,
          SIGTERM or SIGPIPE, and additionally, exit statuses and signals
          specified in SuccessExitStatus=. If set to on-failure, the service
          will be restarted when the process exits with a non-zero exit code,
          is terminated by a signal (including on core dump, but excluding
          the aforementioned four signals), when an operation (such as
          service reload) times out, and when the configured watchdog timeout
          is triggered. If set to on-abnormal, the service will be restarted
          when the process is terminated by a signal (including on core dump,
          excluding the aforementioned four signals), when an operation times
          out, or when the watchdog timeout is triggered. If set to on-abort,
          the service will be restarted only if the service process exits due
          to an uncaught signal not specified as a clean exit status. If set
          to on-watchdog, the service will be restarted only if the watchdog
          timeout for the service expires. If set to always, the service will
          be restarted regardless of whether it exited cleanly or not, got
          terminated abnormally by a signal, or hit a timeout.


E-Mail

Die engliche Archwiki Seite berichtet ausführlich darüber.

Weblinks