What I am looking for, is the equivalent of the pre-stop stanza in upstart, for systemd


You can use one or more ExecStop= directives to add systemd-specific stop commands. See man systemd.service for details.

  • ExecStop= directives are not exactly equivalent to pre-stop stanzas because pre-stop does not get executed when service crashes, whereas ExecStop= is executed regardless of whether the service crashed due to a failure, or was stopped through systemctl – Abhay May 2 '17 at 0:10
  • @Abhay the man for systemd ExecStop claims "Note that the commands specified in ExecStop= are only executed when the service started successfully first. They are not invoked if the service was never started at all, or in case its start-up failed, for example because any of the commands specified in ExecStart=, ExecStartPre= or ExecStartPost= failed (and weren't prefixed with "-") or timed out." ~ freedesktop.org/software/systemd/man/systemd.service.html Note that it isn't called if startup failed. – Wimateeka Jan 29 '18 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.