So by default I am in runlevel 3. During shutdown I switch into runlevel 0. But I am not getting any success if am putting my script (having a curl
call) in /etc/rc0.d/
, as in runlevel 0 network is already stopped and therefore it is not able to do the curl
call.
How to get the desired result ?
Generally in the older SysVinit systems, boot sequence and shutdown sequence were controlled by the alpha-numeric order of symbolic links to your init-script located in each runlevel directory under
/etc/init.d
(or/etc/rc.d/
) where the links numberedS##
(start) were run during boot andK##
(kill/stop) scripts were run during shutdown. The services available at any given point in time are controlled by what is running during the boot or shutdown sequence. For example an older SuSE scheme would be:If you look at the boot/shutdown sequence for runlevel-3 in
/etc/init.d/rc3.d/
you see that the network start and shutdown are controlled byS05network
on boot andK18network
on shutdown. So if you wanted to create a custom script to runcurl
on shutdown prior to the network shutting down, you would need to create an init script and create a soft-link in/etc/init.d/rc3.d
and have it numbered prior to the network services (ssh
, etc.) being taken down. Above if you created and numbered the soft-link to your kill scriptK10curlonsd
(curl on shutdown), it would run aftercron
shutdown, but before any of the network services were taken down.The scheme should still be the same on centos, although your
/etc/init.d
may be/etc/rc.d
, etc., but the general approach will be the same. Let me know if you have any questions.