I need to run a script when the server is going for a shutdown i.e. run level 0. But the catch here is, I need to make a curl call in the script which is not possible in run level 0 as the network will be down.
So my question is how can I achieve this ?
Basically what I am looking for is a solution to run a script when the system goes from run level 3 to run level 0.
Any help is appreciated.
You can do that combining all this together
$ runlevel
, $ who -r
, etc./etc/init.d/
where you check if the current run level is 3
./etc/rc0.d/
with target to your script.That's it, this should work !