Originally posted on StackOverflow, told to come ask over here. To recap that conversation–
- No, I haven't really been able to try making the change to see what happens (not without potentially impacting a running production service).
- RTFM due diligence done. They don't cover this.
My original SO question follows:
Assume I have the following in my systemd
unit file:
Type=forking
Restart=on-failure
Parent process exits with status 0 (child launched successfully). At some later point, the child dies with a non-zero status. What happens? systemd
can track the child daemon process PID:
Process: 1768 ExecStart=/bin/mydaemon (code=exited, status=0/SUCCESS)
Main PID: 1770 (mydaemon)
Is Restart=on-failure
only looking at the parent exit status, or also the child?
Best Answer
I created the following unit file:
The script.sh contains the following:
The myscript.sh contains the following:
Sure enough, every 60 seconds, systemd restarts the service.
As shown here, notice the different PID's and the start times, note that it restarts the parent: