Source

mindref-sbin / sync-time

#!/bin/bash
. /usr/local/sbin/func/random_sleep

server=pool.ntp.org

random_sleep 600 120

# Sync the time with external server
echo "Sync time with $server."
/usr/sbin/ntpdate -s $server || exit 1

# Adjusts clock drift
/sbin/hwclock --adjust

# Set the hardware clock to current system time
/sbin/hwclock --systohc