On Thu, Jan 4, 2018 at 9:50 PM, Mircea Husz <mirceah...@yahoo.com> wrote: > Migrating an init script to systemd, and need to archive logs only if the > service exited normally with a return code 0. I found $SERVICE_RESULT, > $EXIT_CODE, and $EXIT_STATUS but they are in a newer version of systemd, I > am stuck with version 219 on CentOS 7. > > I'd love to run ExecStopPost on a conditional exit status but that's just > not available. Before I get creative with Pre, Start, and Post bash scripts, > is there any straightforward way of handling this kind of thing with systemd > ?
You could query the exit code in post script via systemctl show, the property is called ExecMainCode. Btw, in case you have RH subscription then please open a support case and we can backport this functionality to RHEL/CentOS. Cheers, Michal _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel