I have about a dozen Linux boxes that I occasionally need to run the same command(s) on. Is there an easier way (or automated way) to do this asides from logging on to each machine and running the command, one at a time? It's not the same commands all the time and it's not at a preset time so it's not something ideal for tools like cron
.
There's also ClusterSSH, which, well, does exactly what you think it does. Yay for descriptive naming!
Hm, maybe pconsole is the tool you want.
You should check out Puppet here is a linux.com article on its setup and use
You may try Capistrano. Originally it is a Rails deployment tool, but it grew to do many things with remote machines.
For a more complete aproach to administration of multiple machine you may want to try Chef.
Ansible has ability to do ad hoc commands and is also expandable to do full config management. The ability to match based on groups is excellent.
http://docs.ansible.com/intro_adhoc.html
Don't overlook pssh and dsh either; they're both much like gsh that @Philip Durbin mentioned.
If you are on a KDE desktop, konsole has the "Send Input to all sessions" option. It applies to all the sessions opened in the same konsole window.
I guess I'll copy and paste my answer from Stack Overflow, which people seemed to like. . .
The issue of how to run commands on many servers at once came up on a Perl mailing list the other day and I'll give the same recommendation I gave there, which is to use gsh: http://outflux.net/unix/software/gsh
gsh is similar to the "
for box in box1_name box2_name box3_name
" solution already given but I find gsh to be more convenient. You set up a /etc/ghosts file containing your servers in groups such as web, db, RHEL4, x86_64, or whatever (man ghosts) then you use that group when you call gsh.You can also combine or split ghost groups, using web+db or web-RHEL4, for example.
I'll also mention that while I have never used shmux, its website contains a list of software (including gsh) that lets you run commands on many servers at once. Capistrano has already been mentioned and (from what I understand) could be on that list as well.
You could also try
ssh [user@]hostname [command]
and then loop through the host names.Also take a look at func. Func lets you use a module architecture to control different aspects of a system, from dealing with packages, to running commands, etc. It works on a client/server module over SSL and has a fairly flexible authentication scheme as well.