Operating System - HP-UX
1771261 Members
2175 Online
109004 Solutions
New Discussion юеВ

Writing a scritp to reboot a remote machine

 
SOLVED
Go to solution
Prasad Joshi
Regular Advisor

Writing a scritp to reboot a remote machine

Hi all,

I am writing a script to reboot a remote machine.

In that script, I am just copying another script (name Sreboot) having statement "reboot" to /etc/rc.config.d/ directory and then rebooting the machine.

When the remote machine is restarted again it again reboots because of Sreboot script.
This goes on.

Now I want to stop this.

I am trying to remove script "Sreboot" through ssh connection. but connection gets timed out. Is there any way to remove this file from directory /etc/rc.config.d/

I want to run this test many times. So, i donot want to go in maintianence mode and mannually remove it.

I want a way to remove this file from remote machine.

Can any one help? Is there any other way to do this?

Thanks in advance.
Prasad
13 REPLIES 13
SANTOSH S. MHASKAR
Trusted Contributor

Re: Writing a scritp to reboot a remote machine

Hi Prasad,

What is the content of Script Sreboot ?

-Santosh
RAC_1
Honored Contributor

Re: Writing a scritp to reboot a remote machine

First thing is, for such things, you should nto eb using a file placed in /etc/rc.config.d/. This dir holds config files. If you want to reboot machines remotely, just have ssh/remsh set with root and reboot command in it.
There is no substitute to HARDWORK
Chan 007
Honored Contributor

Re: Writing a scritp to reboot a remote machine

Hi,

Get it to the remote system by GSP/MP, do a single user boot byt interupting the boot process. remove the file.

If you wanted to reboot a remote system, why can't you schedule it via cron.

Chan
Prasad Joshi
Regular Advisor

Re: Writing a scritp to reboot a remote machine

It contains.

#!/bin/csh
reboot &


Thanks for ur concern feedback
Chan 007
Honored Contributor

Re: Writing a scritp to reboot a remote machine

Prasad,
if reboot is what used said, then use my method to stop this. if you don't have GSP/MP, call someone in that data center or raise call with HP.

Chan
Prasad Joshi
Regular Advisor

Re: Writing a scritp to reboot a remote machine

Hi,

I do not want to mannually do it.

Consider there are 2 machines A and B

from B I am doing
# UpDown start A
this copies the script to /etc/rc.config.d/
then reboot machine A for first time
I am using ssh for this

Now machine A goes on rebooting

Now i want a way to do this
# UpDown stop A
this should remove the file from /etc/rc.config.d/

Thanks & reagards
Prasad
Antonio Cardoso_1
Trusted Contributor

Re: Writing a scritp to reboot a remote machine

Prasad,

consider using ssh to remotely run the reboot (or shutdown) command. This is the most secure.

alternaltive: perl + telnet client.
I could provide you an example of this if needed.
SANTOSH S. MHASKAR
Trusted Contributor

Re: Writing a scritp to reboot a remote machine

Hi Prasad,

U r using ssl to reboot sys B from sys A,
instead of keeping ur script in /etc/rc.config.d keep it somewhere else. Since during execution of /sbin/rc all the files in
/etc/rc.config.d r executed to set the config.
variables. If u r placing ur script with a
reboot & command in it the system keeps rebooting.
If keeping system rebooting is not ur intension
then keep this script somewhere other than
/etc/rc.config.d (say /usr/sbin) , I usually
place it there only.


To get rid of repeatative rebooting u have to
get access of ISL of remote server, for this
as suggested by Chan u have to configure
GSM/MP, It is very useful to get it configured.
Through GSM u can boot into single user and remove the script
from /etc/rc.config.d

Hope it helps u.

Regards

-Santosh
Ninad_1
Honored Contributor

Re: Writing a scritp to reboot a remote machine

Prasad,

I am unable to imagine what you are trying to achieve. If you want to reboot your remote machine just once why put script in /etc/rc.confg.d ??
Your local machine can execute a reboot command once through ssh whenever you wish to reboot the remote server.
Now the question remains is are you trying to break the reboot loop now so that you can login/use the remote server - if yes write a script on your local machine which will continuous ping the remote server and if able to reach the remote server run a ssh to replace the Sreboot script in /etc/rc.config.d in the remote server by a dummy script - this can be a blank file with the same name ie Sreboot.

while true
do
if [[ $(ping remote_server -n 2 | grep "%" | cut -f 1 -d "%" | awk '{print $NF}') = "0" ]]
then

sleep 5
fi
done

The reason I have kept the above script in loop is that even after you receive response to ping the other services for network may have not come up yet to eable you copying the file to remote server. Simultaneously you can check if the server has stopped rebooting - then you can interrupt this script on local server.
Then you can ammend what you were doing wrong.

Hope this helps,
Ninad