LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Run the script at machine shutdown. (https://www.linuxquestions.org/questions/linux-newbie-8/run-the-script-at-machine-shutdown-4175454492/)

trumtrak 03-18-2013 02:59 AM

Run the script at machine shutdown.
 
Hi,
I am novice user of RHEL 6.3.
I want to execute a script which will stop some services on my machine when the system stops(I dont want them to go in defunct state). I have copied the script at "/etc/init.d/" and created the soft link for same in "/etc/rc0.d".
But when i shutdown the machine the exceptions comes is "ssh: connect to host localhost port 22: Network is unreachable." My script contains the ssh command . It seems like ssh already gets killed before executing the script. I have created the softlink with name as "S00Execute_at_shutdown".

Can anyone help me to solve it.

lleb 03-18-2013 07:16 AM

if you are shutting down the system, then the network is one of the first things to be placed into a "stop" condition.

post the code you have and be a bit less vague then we can start to help. in short if you are turning off the computer, it should be doing nothing but placing services in stop and then the last thing it will do is stop the kernel as it removes power from the hardware.

nagabhushan 03-18-2013 07:38 AM

Hi trumtrak,

Generally scripts starting with "K" execute first than "S" scripts. Script for sshd is K prefixed. So you might facing that problem.
Visit this link http://www.ghacks.net/2009/04/04/get...itd-directory/ you will get much explanations here.


All times are GMT -5. The time now is 05:43 PM.