I've gone over the documentation for systemd
here https://www.freedesktop.org/software/systemd/man/systemd.service.html.
It states in the ExecStartPre=,ExecStartPost=
section
Note that if any of the commands specified in ExecStartPre=, ExecStart=, or ExecStartPost= fail (and are not prefixed with "-", see above) or time out before the service is fully up, execution continues with commands specified in ExecStopPost=, the commands in ExecStop= are skipped
I have an ExecStartPre
rule being
ExecStartPre=/bin/false
In ExecStopPost
I have an /bin/echo "I'm at ExecStopPost"
.
The service looks like
[Unit]
Description=Test
[Service]
Type=oneshot
ExecStartPre=/bin/echo "I'm at ExecStartPre"
ExecStartPre=/bin/false
ExecStart=/bin/echo "Running Test"
ExecStopPost=/bin/echo "I'm at ExecStopPost"
When it runs and fails, I never see it. Output from syslog looks like
Jun 15 20:48:01 ip-10-0-0-246 echo[8687]: I'm at ExecStartPre
Jun 15 20:48:01 ip-10-0-0-246 systemd[1]: test.service: Control process exited, code=exited status=1
Jun 15 20:48:01 ip-10-0-0-246 systemd[1]: Failed to start test.
Jun 15 20:48:01 ip-10-0-0-246 systemd[1]: test.service.service: Unit entered failed state.
Jun 15 20:48:01 ip-10-0-0-246 systemd[1]: test.service.service: Failed with result 'exit-code'.
I never see my echo.
journalctl -u test.service
of course also has this as it's entry.
Do I need to configure this slightly differently? Or do I need to use OnFailure
?
I need to be able to restart a Conflicts=
on success or failure cases. This will be used in oneshot services triggered by timers.
Oh and this is running on 16.04.6 LTS.