running Shell Script on multiple server.

Hello Folk,
I am monitoring the 5 servers say (server1,server2,server3,server4,server5).
I have to run the script on all these servers to take the daily-backup.

Currently I have the script on individual servers and running that.

What I want that, I want to have the script Only on server1
and want to run it on all the servers.Need the suggestion…

Thanks
Shariq

Pull not push.

i.e. rsync…

rsync -ave ssh source.server:/path/to/source /destination/dir

Unless I’m missing something.

@FeatherMonkey
rsync did’nt solve my problem.
myproblem is to run Single Python-Script on multiple server.

suppose I have PYTHON script ‘backup.py’
on server1 at location username@server1:/home/backup.py
I want to run this script on remaining servers i.e. server2,server3,server4 and so on.

Thanks in advance for any further suggestion.

Thanks
Shariq

Think you’re trying to fit the sqr peg in the round hole.

Or looking at it wrong I don’t know of a way to do what you’re asking that sounds like clustering in my crude opinion. Or executing a script based on one system on another(Still think clustering or distributed processing perhaps is a better fit)

rsync may of been too specific the principle is the same pull don’t push.

Without seeing the code you must be pushing to server 1 some how so don’t re-write the script to pull. Either that or you’re backing up locally to the script.

A quick google showed me there is the abilty to use ssh in python how exactly I didn’t look. To me python is overkill for backup there is plenty of tools around that can do this.

I’m a Linux noob… but couldn’t you make a script that will transfer your script to Server2 then run it, then transfer the script to Server3 and run it, etc.? I do this all the time on my Windows machines and just now starting to learn how to do it on Linux machines. I’ve got something in mind and will test it out. If it works, I’ll post what I came up with.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Why don’t you mount server2 … serverN filesystem with sshfs on
server1 and run the script on it?


VampirD

Microsoft Windows is like air conditioning
Stops working when you open a window.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/

iEYEARECAAYFAkwiIAoACgkQJQ+0ABWtaVn03QCfbLjAPNhg3q3IbB6FdADjGo40
9KIAnj+AAbEz97Z6J8HDBzWI7qqW42rb
=lVKf
-----END PGP SIGNATURE-----

Okay. Just to make things simple…
I made a script that will list the contents of the root directory and print the output to a file. Let’s call this script list.sh.
Then created another script that will send this script to another server and run it. Lets call this script send.sh.
The code was

#!/bin/bash
scp ~/list.sh <username>@<server>:/home/<username>/list.sh
ssh -l <username> <servername> /home/<username>/list.sh
exit

where <username> is the name you log in with and <server> is the name of the server to log in to.

My script worked, except I had to be here to type in the passwords. I hope this helps in some way. It may at least lead you in the right direction.

  • Thomas

Oh I forgot to mention, I had to chmod a+x both files.
Then I just ran the send.sh script and everything worked.

  • Thomas

But this solution, like the rsync one, is in fact only a way to distribute the script to the other systems. And that is not what the OP wants. I even doubt if having the script on an NFS exported directory on server1, to be mounted on the other systems is what he wants. But like FeatherMonkey I muss point out that executing a script (square peg) on a system where it is not available (round hole) is not easy to be solved.

Hi
I’ve done it with perl because my scripts kept getting deleted during
upgrades, I was only collecting some data. The script would telnet to a
server, prepare some data, then ftp it back. The script only ever
existing on my local machine.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.12-0.7-default
up 6 days 14:52, 2 users, load average: 0.00, 0.06, 0.13
GPU GeForce 8600 GTS Silent - Driver Version: 195.36.31