Is it possible to hook some script to shutting down sequence for Linux?

To give you a bit more context processes of nodes of the cluster are started as processes from cluster -master. They are not running as services. However if someone restart a node and didn't stop the appropriate process manually, it causes a troubles because the node hasn't been stopped gracefully.

I would like to avoid this situation. Processes they don't run as services.

  • what's the parent-process of these processes? if this is a service itself, you can sigterm this service or the cgroup. if the processes are detached/nohup, can you identify them by their binary-name? is it possible to create a pidfile?
    – blaimi
    Oct 26, 2020 at 21:14

1 Answer 1


I'd link a script that would shut down the nodes to /etc/rc6.d

It'll run on runlevel 6, that coresponds to shutdown sequence. Link name should be of format KXXName, where XX is a sequence number.

I'm assuming here that you have control over the nodes and you are able to wait for them to shut down gracefully.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .