VMware 時計問題(回顧)

今更ながら、どこにも書いていなかったので、書いておきます。
VMwareの時計問題について、次のような無理矢理な解決方法をとっていた。

VMware Command Line Toolsで配布されているvmwコマンドを使って、ホストOSの時計に対して同期を取ることが出来る。次のコマンドラインは、60秒おきに時計の同期を行う。

$ vmw time -u -r 60

なので、次のスクリプト(/etc/init.d/vmsynctime)はこれを応用して、定期的に自動的に同期を行う。

参考:VMWare for Windows NT and Windows 2000 に関する(いい加減な)話題

#!/bin/sh
# chkconfig: - 20 20
# description: Synchronize the clock of guest machine to the host.

poll() {
        while :
        do
                # vmw actually never returns
                /bin/vmw time -u
                sleep 100
        done;
}

test -x /bin/vmw

case "$1" in
        start)
                poll &
                ;;
        stop|restart|force-reload)
                ;;
        *)
                echo "Usage: $0 {start|stop|restart|force-reload}"
                exit 1
                ;;
esac

exit 0

デーモンとして起動させるには、次のようにする。

$ chkconfig --add vmsynctime
$ chkconfig vmsynctime on
$ /etc/init.d/vmsynctime start