Cron – “NTP socket is in use” messages from ntpdate in syslog

cronntpntpdatesyslog

In cron.log I can see that ntpdate is being triggered from a cron job which is running daily at 23:15

Mar 10 23:15:01 seitan /USR/SBIN/CRON[22407]: (root) CMD (/etc/network/if-up.d/ntpdate)

But I cannot seem to find the cron job that is causing these messages to fill up my syslog

Mar 10 23:15:01 seitan ntpdate[22416]: the NTP socket is in use, exiting

I'm guessing I need to change this cron job to stop the ntp service before this command executes, then start it again afterwards, but I don't know where this is being triggered from. I have checked the cron.daily directory and it only contains a file ntp which only seems to rotate the ntp stats (contents below):

#!/bin/sh

# The default Debian ntp.conf enables logging of various statistics to
# the /var/log/ntpstats directory.  The daemon automatically changes
# to a new datestamped set of files at midnight, so all we need to do
# is delete old ones, and compress the ones we're keeping so disk
# usage is controlled.

statsdir=$(cat /etc/ntp.conf | grep -v '^#' | sed -n 's/statsdir \([^ ][^ ]*\)/\1/p')

if [ -n "$statsdir" ] && [ -d "$statsdir" ]; then
    # only keep a week's depth of these
    find "$statsdir" -type f -mtime +7 -exec rm {} \;

    # compress whatever is left to save space
    cd "$statsdir"
    ls *stats.???????? > /dev/null 2>&1
    if [ $? -eq 0 ]; then
            # Note that gzip won't compress the file names that
            # are hard links to the live/current files, so this
            # compresses yesterday and previous, leaving the live
            # log alone.  We supress the warnings gzip issues
            # about not compressing the linked file.
            gzip --best --quiet *stats.????????
            return=$?
            case $return in
                2)
                    exit 0                  # squash all warnings
                    ;;
                *)
                    exit $return            # but let real errors through
                    ;;
            esac
    fi
fi

I have never touched any of the ntp configuration in the system.

Best Answer

If you have ntp running and configured correctly, there should be no need to run ntpdate at all.

All I typically use it for is to manually set the clock during installation.