シェルスクリプト:NTPD再起動してntpdate実行
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[シェルスクリプト]]
*説明 [#sb74c7e9]
ntpdが動いているのに何故か時刻が同期されていなかった。。~
そんなときに簡易的に使用するためのスクリプトです。
*スクリプト内容 [#s91c9c57]
[準備]
ntpdとntpdateをインストール済みで、ntpdが自動起動オンに...
/rootの直下にbinディレクトリを作成しておき、そこにntp-re...
#!/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 {} ...
find /root/bin/ntp-restart.log.old -mtime +60 | xargs -i...
終了行:
[[シェルスクリプト]]
*説明 [#sb74c7e9]
ntpdが動いているのに何故か時刻が同期されていなかった。。~
そんなときに簡易的に使用するためのスクリプトです。
*スクリプト内容 [#s91c9c57]
[準備]
ntpdとntpdateをインストール済みで、ntpdが自動起動オンに...
/rootの直下にbinディレクトリを作成しておき、そこにntp-re...
#!/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 {} ...
find /root/bin/ntp-restart.log.old -mtime +60 | xargs -i...
ページ名: