Solaris NTP Time Sync

From neil.tappsville.com
Jump to navigationJump to search

Reference: http://www.softpanorama.org/Net/Application_layer/NTP/configuring_a_solaris_ntp_server.shtml

Check if xntpd is running if not its probably not been configured.

The /etc/inet/ntp.server file is a template for configuring an NTP server. Copy this file to /etc/inet/ntp.conf, and edit it to meet your network’s requirements. When viewing the ntp.server file contents, remember that an NTP server is also an NTP client.

On Solaris 9 the /etc/rc2.d/S74xntpd script is executed at system boot time and starts the xntpd process if the /etc/inet/ntp.conf file exists. The xntpd process starts in either the client or the server mode, depending on the contents of the ntp.conf file.

/etc/rc2.d/S74xntpd

#!/sbin/sh
#
# Copyright (c) 1996-1997 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident  "@(#)xntpd.sh   1.7     01/04/25 SMI"

[ ! -d /usr/sbin -o ! -d /usr/lib/inet ] && exit 1

case "$1" in
'start')
        [ -f /etc/inet/ntp.conf ] || exit 0

        ARGS=`/usr/bin/cat /etc/inet/ntp.conf | /usr/bin/nawk '
        BEGIN {
            first = 1
        }
        /^#/ {
            next
        }
        /^multicastclient/ {
            if (first) {
                first = 0
                printf("-s -w -m")
            }
            if (NF == 1)
                printf(" 224.0.1.1")
            else
                printf(" %s", $2)
            next
        }
        /^server 127.127/ {
            next
        }
        /^server|^peer/ {
            if (first) {
                first = 0
                printf("-s -w")
            }
            printf(" %s", $2)
            next
        }
        '`
        if [ -n "$ARGS" ]; then
                # Wait until date is close before starting xntpd
                (/usr/sbin/ntpdate $ARGS; sleep 2; /usr/lib/inet/xntpd) &
        else
                /usr/lib/inet/xntpd &
        fi
        ;;

'stop')
        /usr/bin/pkill -x -u 0 '(ntpdate|xntpd)'
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac
exit 0

/etc/inet/ntp.conf

server ntp.master.host
server 10.111.69.10 prefer
server 10.111.69.11
server 146.171.37.140
driftfile       /etc/inet/ntp.drift

/etc/rc2.d/S74xntpd start

wait a few moments and the time should update and the ntp service will be running