[Linux] Difference between simple and oneshot in systemd service Type option

Summarize difference between simple and oneshot in systemd service’s Type option


Environment and Prerequisite

  • Linux
  • systemd


Goal

  • Summarize by myself about difference between simple and oneshot in systemd service’s Type option.
  • This post does not explain about systemd or service
  • I referred to many things on Reference.


systemd service type

simple

[Service]
Type=simple
  • It changes its state to active because its option considers process started successfully just after starting the main process. It does not wait until the main process exits and moves to next systemd unit. If you are in condition like wait for the network up and then run the next systemd unit, you rather use oneshot option or use other options.
  • It can only has one ExecStart=.
  • State will be changed to active after running process and it will be changed to inactive after finish of it.



oneshot

[Service]
Type=oneshot
  • It waits until the main process exits in activating state after running the main process. It moves to next systemd unit after the main process exits.
  • It can have multiple ExecStart=.
  • State will be changed to activating after running process and it will be changed to inactive after finish of it. If use RemainAfterExit=true option, then state will be changed to active not inactive(even though there is no running process!)


common things between two

  • Both don’t care about forking child processes. Use Type=forking instead.


Reference

[Python] 파이썬(Python) List Comprehensions

> 파이썬(Python) List Comprehensions에 대해 알아보자.## 환경- Linux- Python 3.X.X## 파이썬(Python) List Comprehensions### List Comprehensions```pythonre...… Continue reading