[Linux](EN) 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 useoneshot
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 toinactive
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 toinactive
after finish of it. If useRemainAfterExit=true
option, then state will be changed toactive
notinactive
(even though there is no running process!)
common things between two
- Both don’t care about
forking
child processes. UseType=forking
instead.