I’m using systemd v250.5. I want to pass EXIT_CODE
& EXIT_STATUS
of service when it fails.
I have followed the example provided in systemd doc – https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Examples
A service myfailer.service
which can trigger an OnFailure= dependency.
[Unit]
Description=Service which can trigger an OnFailure= dependency
OnFailure=myhandler.service
[Service]
ExecStart=/bin/myprogram
A service myhandler.service
can be triggered by myfailer.service
service.
[Unit]
Description=Acts on service failing or succeeding
[Service]
ExecStart=/bin/bash -c "echo $MONITOR_SERVICE_RESULT $MONITOR_EXIT_CODE $MONITOR_EXIT_STATUS $MONITOR_INVOCATION_ID $MONITOR_UNIT"
On failure, myhandler.service
service gets invoked but the value for $MONITOR_SERVICE_RESULT
, $MONITOR_EXIT_CODE
, $MONITOR_EXIT_STATUS
, $MONITOR_INVOCATION_ID
, $MONITOR_UNIT
are empty