![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Basic Java Persistence API Best Practices | iBot | Oracle Updates (RSS) | 0 | 06-06-2008 04:10 PM |
| Korn Shell Best Practices | mtravis | Shell Programming and Scripting | 1 | 02-14-2008 12:11 PM |
| Emergency boot | dags | SCO | 2 | 04-14-2005 07:00 AM |
| Scripting Best Practices | toddjameslane | UNIX for Dummies Questions & Answers | 5 | 03-26-2005 11:09 AM |
| User generated FAQ and Best Practices section | kduffin | Post Here to Contact Site Administrators and Moderators | 5 | 11-21-2003 06:24 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
emergency shutdown best practices.
Has anyone implemented or have suggestions on how to shutdown many remote unix/linux servers from a single script initiated from 1 server?
I need this to execute in parallel as time is not on my side. Our ups is sadly underrated and will die in approximately 15 minutes. (There is not any money in the budget to upgrade the ups.) |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
If you can ssh around as root
Code:
for host in `cat hostlist`; do ssh $host shutdown <arguments>;done |
|
#3
|
|||
|
|||
|
If you have more than 15 minutes to plan for "emergency shut down" of your servers, I'd recommend:
1. All applications that are running have corresponding startup and shutdown scripts in rc.* 2. Identify the order that your hosts should be shutdown in - NIS or LDAP should shutdown last, NFS servers second last... NTP would go first... 3. Write scripts. You need to send a wall to all users connected informing them of an impending outage. You need to ensure that you send the right shutdown options to the right OS types. You need to create for each command that you are sending - for audit and CYA purposes later. 4. Inform your business/clients/users that these are the "emergency shutdown" procedures. Get them to sign-off and buy into them. If they have special requirements, amend your policy to include those. Ensure that you have adequate time to shutdown storage devices that may have a great deal of data in cache. Ensure that you have adequate time to shutdown tape storage systems, as the robotics may need more time to get to "home" than you might expect. There is no shortage of things that you could do, but this should get you started. Last edited by avronius; 10-08-2008 at 11:17 AM. Reason: Grammer |
|
#4
|
|||
|
|||
|
Here in lies the problem. Our network security officer will not allow ssh as root. Also, we have many "flavors" of unix/linux which have different shutdown options. I tried something like this but it does not work on all the servers. (They do not like the <<\EOT...EOT construct)
$1 is list of remote servers. mbaker has sudo root privilege cat $1 | while read X do echo "Starting shutdown of $X" ssh -T ${X} << \EOT >> Emergency_shutdown.log 2>> error.log name=`uname -n` echo "name = $name" type=`uname -a | awk '{print $1}'` echo "type = $type" if [ "$type" = "SunOS" ] then echo "Emergency shutdown initiated for $name." # sudo -u root shutdown -y -i5 -g0 "Emergency shutdown started!!!!!" & fi if [ "$type" = "Linux" ] then echo "Emergency shutdown initiated for $name." sudo -u root /sbin/shutdown -k now "This is just a test. Not really re-booting." < /dev/null > /dev/null 2>&1 & fi EOT if [ $? -ne 0 ] then echo "Host $X connect failed." fi done exit 0 |
|
#5
|
||||
|
||||
|
the best way is to create an script per server. called something like
"emergency-shutdown.sh" and call that one. and put all the os specific commands on each server its harder to maintin maybe, but is cleaner, and more flexible. |
|
#6
|
|||
|
|||
|
can you do this as user mbaker:
Code:
for host in `cat hostlist`; do ssh $host sudo -u root ifconfig -a;done Depending on how your systems are config'd, you may be able to sudo without providing a password. If you DO need a password to do the sudo, you could add some scripting magic to wait and apply the password, but it's not terribly secure... |
|
#7
|
|||
|
|||
|
Good point Broli - since you are already using sudo, create the shutdown scripts (one script for all hosts - perform the OS check locally), and give mbaker the right to run the shutdown script.
Then, your script would simply be: Code:
for host in `cat $hostlist` do; ssh $host emergencyShutdown <flags/options>;done |
|||
| Google The UNIX and Linux Forums |