Debianでは、S60以降ではシステムクロックがセットされていると期待してよい。このスクリプトが走るのは、システムクロックがセットされた後であるべきなので、/etc/init.d/rcS.d/S61あたりにリンクしておくとよい。
なお、別途sysctl.confに、xen.independent_wallclock = 1の設定が必要。
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: ntpdate
# Required-Start: networking
# Required-Stop: hwclock
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Adjust clock on startup.
### END INIT INFO
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
[ -x /usr/sbin/ntpdate ] || exit 0
. /lib/lsb/init-functions
case "$1" in
start|force-reload|restart)
log_action_begin_msg "Adjusting clock"
if ntpdate 0.debian.pool.ntp.org; then
log_action_end_msg $?
else
log_action_end_msg $?
fi
;;
stop)
;;
*)
echo "Usage: /etc/init.d/ntpdate {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0
| | 2009-06-02 00:50