Need a script to run on multiple mail servers..

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!

cron would run it for you, after you install it once a host.

ssh with passwordless login is very good for scripting going to remote hosts, but you may have to establish the local env before running the command:

 
while read hostname
do
 echo ==== $hostname ====
 ssh -n $hostname ". ./.profie ; /opt/bss/bin/snmptable -CB -v2c -c P67LzuBm $hostname hrStorageTable" 2>&1 | cat
 echo
done <host_file

Lets's avoid "hostname" as an environment variable name. See "man hostname".

Thanks for the replies. 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 from there...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 :slight_smile:

If you write a watcher, it has faster restart reflexes!