- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Writing a scritp to reboot a remote machine
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:11 PM
тАО03-30-2006 10:11 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:16 PM
тАО03-30-2006 10:16 PM
Re: Writing a scritp to reboot a remote machine
What is the content of Script Sreboot ?
-Santosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:21 PM
тАО03-30-2006 10:21 PM
Re: Writing a scritp to reboot a remote machine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:23 PM
тАО03-30-2006 10:23 PM
Re: Writing a scritp to reboot a remote machine
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:24 PM
тАО03-30-2006 10:24 PM
Re: Writing a scritp to reboot a remote machine
#!/bin/csh
reboot &
Thanks for ur concern feedback
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:25 PM
тАО03-30-2006 10:25 PM
Re: Writing a scritp to reboot a remote machine
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:33 PM
тАО03-30-2006 10:33 PM
Re: Writing a scritp to reboot a remote machine
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:47 PM
тАО03-30-2006 10:47 PM
Re: Writing a scritp to reboot a remote machine
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 10:55 PM
тАО03-30-2006 10:55 PM
Re: Writing a scritp to reboot a remote machine
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-30-2006 11:41 PM
тАО03-30-2006 11:41 PM
Re: Writing a scritp to reboot a remote machine
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2006 12:25 AM
тАО03-31-2006 12:25 AM
Re: Writing a scritp to reboot a remote machine
Actually, I am doing a test case which requires remote machine to be rebooted repeated.
I need to do this n number of times with n number of machines. Hence, I wrote a script. Now, I am able to reboot machines repeatedly.
I can stop this continuos reboot mannually, but want a method through which i can stop this process from remote machine.
I have written a script for this stop perpose also, which establishes a ssh connection and removes this Sreboot file from that directory, but is not working ssh connection is timed out everytime.
I am not sure whether sshd is started before the scripts in /etc/rc.config.d/ are ran.
Can you pl. help me in this case?
Thanks for your replay.
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2006 12:42 AM
тАО03-31-2006 12:42 AM
Re: Writing a scritp to reboot a remote machine
you should be able to achive this by placing a file on your controlstation/server for each remote server you want to boot, like i.e. /var/bootflags/reboot.
Then in the script copied to each server check for the existance of this remote file and reboot only if it is there.
This way you can interrupt the instant-reboot by deleting/renaming the file on your local machine.
To be sure you have ssh available on the remote server you should place the remote script into /sbin/init.d and have it called via an appropriate link in /sbin/rc2.d after sshd started up.
regards,
Bernd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2006 10:15 PM
тАО03-31-2006 10:15 PM
SolutionI think the way forward for you is as below
Assuming you want your remote servers to boot upto init level 3 and then reboot and continue this untill you want it to reboot.
On Local server
1. Write a script which will issue a reboot command to the remote server
2. You must have a file for each remote server in you local server. The file will have either CONTINUE or STOP word in it.
Whenever you want to start rebooting a particular remote server - open the corresponding file on your local server and write the word CONTINUE, run the script mentioned in step 1 to give the reboot command to that particular remote server.
Whenever you want the remote server to stop edit this file and write the word STOP
On remote server
1. Create a script in /sbin/init.d with name say srvreboot - Check other scripts in this location to understand the general format of the script - something like this:
case "$i" in
'start') commands to execute
;;
'stop') echo ""
;;
esac
commands to execute - Here call a script which will reside on the remote server. This script checks the contents of the file meant for this remote server in your local server through ssh and if contents are CONTINUE then issues command reboot; if contents are STOP then just echo "" .
2. In /sbin/rc3.d create a link to the above created file
cd /sbin/rc3.d
ln -s /sbin/init.d/srvreboot S99srvreboot
By mentioning S99 - will ensure that the remote server has booted and started all the services and your srvreboot script is executed almost as the remote server has booted to run level 3.
Thus by doing so you wont face the problem of ssh timeout. You can instruct the remote server when to start rebooting and each remote server will check the respective file on your local server to check if it is supposed to stop rebooting.
This is just the logic. I am sure you will be able to develop the scripts yourself. If still you face any problem. Or the above does not satisfy your requirement, let know.
Best of luck.
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2006 08:24 PM
тАО04-04-2006 08:24 PM