Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

yum update script

Posted on 2014-12-15
1
Medium Priority
?
454 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 12

Accepted Solution

by:
andreas earned 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.
Suggested Courses
Course of the Month6 days, 15 hours left to enroll

782 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