Shell script to roll new *.conf file

Posted on 2008-11-10
Last Modified: 2013-11-17
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.
Question by:jdenver247
    LVL 48

    Accepted Solution

    I'm sure you've had the usual lectures about using ssh instead of rsh, so I won't go there.

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

    Open in new window

    LVL 68

    Assisted Solution

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


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

    Open in new window

    LVL 68

    Expert Comment

    Oh sorry,
    this was an overlap!

    Seems some people are too fast for me ...


    Author Comment

    Thanks both the codes are working

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
    Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
    This tutorial goes over how to archive and restore FreeBSD jails that are managed by ezjail.
    Video by: Phil
    This video goes over how to configure and start a jail in FreeBSD.  This video is meant to supplement the article included with this course.

    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

    8 Experts available now in Live!

    Get 1:1 Help Now