Shell script to Shutdown Computers on Cluster


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to Shutdown Computers on Cluster
# 1  
Old 12-08-2009
Question Shell script to Shutdown Computers on Cluster

Hello all.

I have built a cluster of 9 Macs for computational chemistry and I need a shell script that I can use from one computer to all the rest to shutdown.

I have modified all of the Macs so that there is pass-wordless ssh. As well, I have modified each "visudo" file on each machine by adding the line

Quote:
%users localhost=/sbin/shutdown -h now
The computer names are as follows: G5-1, G5-2, G5-3, etc up to G5-9. There are also two named G4-1 and G4-2.

If I type in a terminal

Quote:
$ ssh -f G5-2 "sudo shutdown -h now"
then G5-2 will shutdown.

What I was wondering was is there a way to write a script that I can execute from the main machine (which is G5-1) that will send this line to all of the machines and then wait 2 minutes and shut itself down?

That is, the script would send the shutdown command to G5-2, G5-3, G5-4, G5-5, G5-6, G5-7, G5-8, G5-9, G4-1 and G4-2. Then wait 1 minute and then shut itself down.

Please help.

Thanks.
# 2  
Old 12-08-2009
put your server list in a file, such as

Code:
$ cat Server_list
G5-1
G5-3
G5-4
...
G5-9

run below script Down_all

Code:
$ cat Down_all

cat Server_list |xargs -i ssh {} "sudo shutdown -h now"
sleep 120
sudo shutdown -h now

or

Code:
for i in `cat Server_list`
do
  ssh $i "sudo shutdown -h now"
done
sleep 120
sudo shutdown -h now

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

Shutdown Oracle DB on SunOS Cluster

Hi, I've this Oracle database version: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production Oracle is install in a SunOS DBSERVER1 5.11 11.2 sun4v sparc sun4v cluster (Not RAC environment) DBSERVER1 is node active and DBSERVER2 is node inactive ... (4 Replies)
Discussion started by: db_senior
4 Replies

2. Shell Programming and Scripting

Help required for Oracle database shutdown script conversion from shell to perl

Please tell me how to convert below program from shell script to perl. Same commands need to use in shutdown, just need program help for startup. export ORACLE_BASE=/home/oracle1 lsnrctl start lndb1 sqlplus '/ as sysdba' startup; (2 Replies)
Discussion started by: learnbash
2 Replies

3. Shell Programming and Scripting

Need help on shell script to monitor each user cpu use on a cluster over time

Hi, I am relatively new to the cluster administration and shell scripting. I need help on a shell script which can help me determine how many cpu's over time, any particular ( or all registered users on a cluster ) are using. To generate data say over a period of week and list of users and their... (6 Replies)
Discussion started by: anuj06
6 Replies

4. UNIX for Dummies Questions & Answers

Script to force Oracle database shutdown when shutdown immediate does not work

I have Oracle 9i R2 on AIX 5.2. My Database is running in shared server mode (MTS). Sometimes when I shutdown the database it shutsdown cleanly in 4-5 mints and sometimes it takes good 15-20 minutes and then I get some ora-600 errors and only way to shutdown is by opening another session and... (7 Replies)
Discussion started by: aixhp
7 Replies

5. Solaris

Shutdown the package in SUN cluster

Hi, I have a SUN cluster system. I want to know what script do when the SUN cluster shutdown the package as I may need to modify it ?? Where can I find out this information in the system?? In which directory and log file ??? Any suggestion ??? (5 Replies)
Discussion started by: chuikingman
5 Replies

6. Shell Programming and Scripting

how to check all the applications are in cluster using shell script

Hi I have an application running in four different node.The server is tomcat.Each node in each tomcat server.How do i check whether all the nodes are in cluster using shell script. any command to check this would be of great use.:) (2 Replies)
Discussion started by: ahamed
2 Replies

7. Shell Programming and Scripting

Shell script to invoke db startup/shutdown

Hi all, I have a shell script which does db shutdown ..the script snippet which does this is as follows: function call_sql_plus { ${SQLPLUS:-sqlplus} -s /nolog <<EOF EXIT; EOF if then echo "Error occurred while calling sqlplus " ... (3 Replies)
Discussion started by: KrishnaSaran
3 Replies
Login or Register to Ask a Question