Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script needed to run on muliple servers at the same time..

Status
Not open for further replies.

hiathiei

Technical User
Jan 31, 2011
5
US
Hello,

I am a Unix newbie and I need a script in which I can run a command on multiple servers at work. The command is to start a storage process and I am sick of doing it manually on all servers..

Here's the command:

/opt/bss/bin/snmptable -CB -v2c -c P67LzuBm hostname hrStorageTable

"hostname" is the name of the server like hrndva-pop01.mail.rr.com etc.

If anyone can help me, I would greatly appreciate it. I believe I would have to do a for loop in the script?

Thanks!
 
Thanks for the response. Basically these processes die down on multiple servers at the same time and then I have to manually log in to the admin server and run the command for each server manually...I replace the "HOSTNAME" part with the name of the server and run it multiple times to make sure it's started on all servers..was just trying to see if I can make life a bit easier :)
 
Do you have a file with the name of the servers ?
Which shell are you using ?
A starting point (ksh code):
Code:
for h in $(</path/to/hostnames.lst); do
  /opt/bss/bin/snmptable -CB -v2c -c P67LzuBm $h hrStorageTable
done

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV, thanks for the response and the code..where do I put all the hostnames in the script or how do I put them there? I don't have a file with all the hostnames but I do have all the host names that the process needs to be started on..

(</path/to/hostnames.lst)=====> can I put all the hostnames here and seperate them with commas or any other character? I am a unix newbie so apologize for asking a stupid question =) also, what does the lst at the end of the hostname do? is it just a list? thanxx
 
for h in hostname1 hostname2 ... hostnameN; do
/opt/bss/bin/snmptable -CB -v2c -c P67LzuBm $h hrStorageTable
done

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
So, should I add the hostname1 hostname2 .. before the parenthesis?

for h in $(</path/to/hostnames.lst); do
 
Please, try to to make sense with the help we offer ....
 
Ok got it now..apologize for any inconvenience :)
 
hostnames.lst need only consist of a simple list of your servers, each on a seperate line (no other delimiters needed, and no blank lines preferably):

server1
server2
and so on

The internet - allowing those who don't know what they're talking about to have their say.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top