Wednesday, December 9, 2009

Changing the ntpdate in various unix OS's

One of the frequent bothers of working with multiples OS's and machines on a daily basis is getting confused with the commands and much worse getting stuck

This one keeps biting me again and again
Machines run out of sync and start failing in tests miserably

And this time the timeserver was decommisionned and so had to reset the ntpdate in all the machines

For Solaris 10:
/ aroot@goldberry> ntpdate newtimserver.nithya.com
16 Oct 17:03:51 ntpdate[2246]: the NTP socket is in use, exiting

Workaround
Have the following entry in /etc/ntp.conf
server newtimserver.nithya.com
Then restart ntp by command:
svcadm restart svc:/network/ntp:default

For Solaris 9 :

ntpdate newtimserver.nithya.com
16 Oct 17:03:51 ntpdate[2246]: the NTP socket is in use, exiting

Workaround:
svcadm is available only from sol10
I was searching for /etc/init.d/ntpd but couldnt find it
Check the /etc/rc2.d for ntp
[cobalt6 37] rc2.d > grep "ntp" *
S74xntpd:#ident "@(#)xntpd.sh 1.7 01/04/25 SMI"
S74xntpd: [ -f /etc/inet/ntp.conf ] || exit 0
S74xntpd: ARGS=`/usr/bin/cat /etc/inet/ntp.conf | /usr/bin/nawk '
S74xntpd: # Wait until date is close before starting xntpd
S74xntpd: (/usr/sbin/ntpdate $ARGS; sleep 2; /usr/lib/inet/xntpd) &
S74xntpd: /usr/lib/inet/xntpd &
S74xntpd: /usr/bin/pkill -x -u 0 '(ntpdate|xntpd)'
[ ]



So You can kill the existing ntpdate - /etc/init.d/xntpd stop or /etc/rc2.d/S74xntpd stop

And run ntpdate newtimserver.nithya.com again

Linux:

Use the -u option
/usr/sbin/ntpdate -u timeserver.sfbay.sun.com