Solved

yum update script

Posted on 2014-12-15
1
401 Views
Last Modified: 2014-12-19
Hi everyone,
I need a script to trigger yum update on a bunch of servers in a seperate list. The list would contain ip address only.
The script would be run from a rhel server on the same subnet as the other servers, and it already has the public key in the other servers authorized keys file

The script im starting with is below...but it would like for the script to reference a list of ip address in the same directory as the script.

#!/bin/bash
# You must have ssh public and private key installed.
#
hosts=(
"ssh root@192.168.100.10 -t sudo  '/usr/bin/yum update -y'"

"ssh root@192.168.100.11 -t sudo  '/usr/bin/yum update -y' "
      )
# simply run array item
for c in "${hosts[@]}"
do
    $c
done
0
Comment
Question by:Peter Kuczynski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
andreas earned 500 total points
ID: 40501617
#!/bin/bash
hosts=$(cat $1)
for i in $hosts ;do
ssh root@$i -t sudo '/usr/bin/yum update -y'
done

then call script with

./scriptname filename.txt

filename.txt should have one ip in one line

each line one ip
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question