5

I have a systemd service controlling some hardware, let's take lamps as a good example. It is OK to restart the service, or reboot the PC, because it is safe that the lamps are left switched on for some while.

However if (and only if) the system is going to halt (power off), I want to do not only the regular cleanup, but also to switch the lights off, i.e. to stop the service in a sligthly different way.

In all mentioned cases (service restart, reboot, halt) the ExecStop command is executed the same way. How can I distinguish between these cases or otherwise know if systemd is doing poweroff or not?

Your Answer

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

Browse other questions tagged or ask your own question.