Solved

yum update script

Posted on 2014-12-15
1
342 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Check if a filw is immutable for a certain amount of time 6 61
How to learn Linux? 10 60
Backup & Restore 3 54
000webhost.com default error log 1 27
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…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

776 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