LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-28-2013, 08:53 PM   #1
bkarthick
Member
 
Registered: Apr 2009
Posts: 56

Rep: Reputation: 0
how to run a script in all servers at a time.


Hi

We have around 200+ servers and in each server there are 400 users residing.i Wrote a script which will fetch the secondary group of all users.In each server i ran the script to get the information.Is there a way to run the script in all servers at a time.
 
Old 02-28-2013, 09:26 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Efficient way is to set password less authentication on all servers and then add a loop in your script plus a file containing a list of the servers:
Code:
SERVER=/tmp/serverlist.txt
while read -r server
do
ssh user@$server "command"
done < $SERVER
--- INFO. ADDED ----

Check this tutorial for password-less login using ssh.
Note: You will need to login on all servers then, and put ssh keys there.

Last edited by shivaa; 02-28-2013 at 09:31 PM. Reason: Information added
 
Old 02-28-2013, 10:20 PM   #3
cbtshare
Member
 
Registered: Jul 2009
Posts: 610

Rep: Reputation: 42
If by the phrase "At the same time" you mean synchronized . Then the best way is make the servers NTP clients and then setup a cron job.
 
Old 03-01-2013, 03:38 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by shivaa View Post
Efficient way is to set password less authentication on all servers and then add a loop in your script plus a file containing a list of the servers:
Code:
SERVER=/tmp/serverlist.txt
while read -r server
do
ssh user@$server "command"
done < $SERVER
In this case don't forget to add the -n option to ssh, for reasons explained here.
 
Old 03-01-2013, 09:59 AM   #5
jk04
LQ Newbie
 
Registered: Feb 2013
Posts: 1

Rep: Reputation: Disabled
Are you using a configuration management tool such as puppet? If yes, then you might want to investigate using it for command execution on remote servers.
 
Old 03-01-2013, 10:05 AM   #6
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
Programs like these enable running commands on multiple hosts.
fanout - http://www.stearns.org/fanout/README.html
pdsh - http://code.google.com/p/pdsh/

Another comment suggests configuration management (puppet/chef/cfengine).
 
Old 03-09-2013, 01:43 AM   #7
bkarthick
Member
 
Registered: Apr 2009
Posts: 56

Original Poster
Rep: Reputation: 0
Hi All,

Thanks i got it...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Run shell script on multiple linux servers vanish78 Linux - Newbie 5 05-16-2012 11:42 AM
How to run same script on multiples servers s_linux Linux - General 1 07-21-2009 03:52 PM
Need a script to synchronize with public time servers basis1980 Linux - Newbie 3 11-28-2007 10:34 AM
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 09:15 PM
can IMAP and POP3 servers run in the same time? htm Linux - Networking 1 03-24-2004 01:43 AM


All times are GMT -5. The time now is 06:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration