Running Linux commands on many servers at a time

"Consistency is the last refuge of the unimaginative."

Running Linux commands on many servers at a time

I’ve been busy at work lately… setting up a new patch process to include implementation, migration from our old, counter-intuitive system (apt on Red Hat servers, :|), so lots of registering systems with Spacewalk has been necessary (until we finish a Puppet module that is).

During our regularly scheduled patching, we have to do blocks of 80+ servers at a time once in a while.  Until the module is done, it’s necessary to connect to all of them manually and run some commands.  I’ve been using ClusterSSH for a little while now, and figured I’d share a quick script that will read a list of system names from a variable, then launch blocks of ClusterSSH windows (the number of windows also based on a variable).

Here it is, boring and not the greatest way to run commands on multiple systems, but it works in a bind…

if [ "$(rpm -qa | grep  ${PKG})x" == "x" ]; then
	echo "$PKG is not installed, you should install it using your favorite package manager first.";
	exit 1
	echo "$PKG is installed, continuing";
if [ $(rpm -qa | grep -q 
for i in $(awk '{print $1}' /tmp/asdf); do
	if [ $((${COUNT} % ${ATATIME})) -eq 0 ] ; then
		echo $SERVERS;
		cssh $SERVERS;

No Comments

Add your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.