説明†ntpdが動いているのに何故か時刻が同期されていなかった。。 スクリプト内容†[準備] ntpdとntpdateをインストール済みで、ntpdが自動起動オンになっている場合。 /rootの直下にbinディレクトリを作成しておき、そこにntp-restart.shを作る。 #!/bin/bash /etc/init.d/ntpd stop if [ $? -eq 0 ]; then ntpdate ntp.jst.mfeed.ad.jp else killall ntpd ntpdate ntp.jst.mfeed.ad.jp fi /etc/init.d/ntpd start if [ $? -eq 0 ]; then echo `date` NTPD restart success. else echo `date` NTPD restart failed. fi ### ログローテーション ログに30日間残す。 30日経過したログファイルは.oldとする。 60日経過した.oldファイルは.old.1とし、次回スクリプト実行時に削除される。 if [ -e /root/bin/ntp-restart.log.old.1 ]; then rm /root/bin/ntp-restart.log.old.1 fi find /root/bin/ntp-restart.log -mtime +30 | xargs -i {} ntp-restart.log.old find /root/bin/ntp-restart.log.old -mtime +60 | xargs -i {} ntp-restart.log.old.1 |