What is the difference between Systemd Service Type oneshot and simple

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

What is the difference between Systemd Service Type oneshot and simple



What is the difference between systemd service Type oneshot and simple?
This link states to use simple instead of oneshot for timers. I am not able to understand it correctly.


systemd


Type


oneshot


simple


simple


oneshot




2 Answers
2



The Type=oneshot service unit:


Type=oneshot



blocks on a start operation until the first process exits, and its state will be reported as "activating";



once the first process exits, transitions from "activating" straight to "inactive", unless RemainAfterExit=true is set (in which case it becomes "active" with no processes!);


RemainAfterExit=true



may have any number (0 or more) of ExecStart= directives which will be executed sequentially (waiting for each started process to exit before starting the next one);


ExecStart=



may leave out ExecStart= but have ExecStop= (useful together with RemainAfterExit=true for arranging things to run on system shutdown).


ExecStart=


ExecStop=


RemainAfterExit=true



The Type=simple service unit:


Type=simple



does not block on a start operation (i. e. becomes "active" immediately after forking off the first process, even if it is still initializing!);



once the first process exits, transitions from "active" to "inactive" (there is no RemainAfterExit= option);


RemainAfterExit=



is generally discouraged because there is no way to distinguish situations like "exited on start because of a configuration error" from "crashed after 500ms of runtime" and suchlike.



Both Type=oneshot and Type=simple units:


Type=oneshot


Type=simple


Type=oneshot


KillMode=none





intelfx says that the Type=oneshot service unit "can have no ExecStart=". This is not true. In fact, services of type oneshot can have multiple ExecStart= directives. See any recent man page for systemd.service for more information.
– rlandster
Oct 22 '17 at 1:09


Type=oneshot


ExecStart=


oneshot


ExecStart=


systemd.service





@rlandster: Why is this "not true"? systemd.service(5) says under ExecStart=: "Unless Type= is oneshot, exactly one command must be given. When Type=oneshot is used, zero or more commands may be specified."
– intelfx
Oct 22 '17 at 1:22


ExecStart=





agree that "can have no" is confusing. that is not true. but i think you can't have ExecReload
– Tony
Apr 2 at 1:43


ExecReload





By "can have no" I assume that @intelfx meant "can have zero or more," or "does not require a," and not "can't have any." However, rewording it for clarity would help future readers.
– seh
May 1 at 18:17





@rlandster alright, reworded for clarity
– intelfx
May 2 at 19:13



From systemd's point of view, Type=simple is kind of fire and forget. Systemd just forks a process defined in ExecStart= and goes on its way, even if the process fails to start.


Type=simple


ExecStart=





Type=simple processes are still monitored by systemd, and will be restarted depending on the value of the Restart setting.
– ldx.a.ldy.c
Feb 1 at 16:51


Type=simple


Restart






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

PySpark count values by condition

Mass disable jenkins jobs