http://project.altservice.com/http://project.altservice.com/favicon.ico?16163160252013-12-17T20:27:44ZALT Project ManagementGNU/Linux Administration - Support #231: Managing Multiple Upgrades on Multiple Servers Using a Simple Shell Scripthttp://project.altservice.com/issues/231?journal_id=3952013-12-17T20:27:44ZDaniel Curtistechsupport@altservice.com
<ul></ul><p>I needed to tweak the script in order to get the servers to upgrade properly. I also added separator lines that allows easier identification of which server is working at the moment.</p>
<pre>
#!/bin/bash
# Script to update and upgrade listed servers
hosts="machine1 machine2 machine3 machine4";
sep="==============================================================================";
# Run update and upgrade command on (1)localhost then (2)each remote host
apt-get update
apt-get -y upgrade
for i in $hosts;
do
echo -e "\n"$sep
echo -e "--> "$i"\n";
ssh root@$i "apt-get update"
ssh root@$i "apt-get -y upgrade"
done;
</pre><br />Note: I needed to use the <strong><code>-e</code></strong> flag with <code>echo</code> in order to allow the <code>\n</code> special character to work correctly. GNU/Linux Administration - Support #231: Managing Multiple Upgrades on Multiple Servers Using a Simple Shell Scripthttp://project.altservice.com/issues/231?journal_id=16292015-02-16T05:35:03ZDaniel Curtistechsupport@altservice.com
<ul><li><strong>Project</strong> changed from <i>21</i> to <i>GNU/Linux Administration</i></li><li><strong>Category</strong> set to <i>Shell Scripts</i></li></ul>