Solved

yum update script

Posted on 2014-12-15
1
326 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
1 Comment
 
LVL 11

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now