![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Basic Java Persistence API Best Practices | iBot | Oracle Updates (RSS) | 0 | 06-06-2008 07:10 PM |
| Korn Shell Best Practices | mtravis | Shell Programming and Scripting | 1 | 02-14-2008 03:11 PM |
| Emergency boot | dags | SCO | 2 | 04-14-2005 10:00 AM |
| Scripting Best Practices | toddjameslane | UNIX for Dummies Questions & Answers | 5 | 03-26-2005 02:09 PM |
| User generated FAQ and Best Practices section | kduffin | Post Here to Contact Site Administrators and Moderators | 5 | 11-21-2003 09:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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.) |
|
||||
|
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 02:17 PM.. Reason: Grammer |
|
||||
|
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 |
|
||||
|
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... |
|
||||
|
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 |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|