• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Shell script to roll new *.conf file

I have 27 aixservers and I want to add couple lines in my /etc/ntp.conf file. RSH is enabled in the enviroment. All the servers have the present conf file
root@aixserver14 # cat ntp.conf
#AIX Only /etc/ntp.conf:
# Updated NTP Conf for AIX Servers
# - rcvs updates from DNS:
#
disable auth
disable bclient
disable pll
disable monitor
server ntp1
logconfig =syncall +clockall
driftfile /var/log/ntp.drift
tracefile /var/log/ntp.trace

I want to add the below to the present configuration file
server ntp2
server ntp3
server ntp4

Before making any changes I want to back the file up and make necessary changes. So can anybody suggest.
0
jdenver247
Asked:
jdenver247
  • 2
2 Solutions
 
TintinCommented:
I'm sure you've had the usual lectures about using ssh instead of rsh, so I won't go there.


#!/bin/sh
for host in `cat /file/with/hosts`
do
  rsh $host "cp /etc/ntp.conf /etc/ntp.conf.bak"
  rsh $host 'echo "server ntp2\nserver ntp3\nserver ntp4" >>/etc/ntp.conf'
done

Open in new window

0
 
woolmilkporcCommented:
Hi again,
part of the following you will already know from your last problem.
The same things I wrote there apply here, too.

wmp


#!/bin/ksh
for srv in $(cat ~/ntphosts)
do
ssh $srv \
     'cp -p /etc/ntp.conf /etc/ntp.conf.backup
      echo "server ntp2 \n server ntp3 \n server ntp4" >> /etc/ntp.conf'
done

Open in new window

0
 
woolmilkporcCommented:
Oh sorry,
this was an overlap!

Seems some people are too fast for me ...

wmp
0
 
jdenver247Author Commented:
Thanks both the codes are working
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now