Linux 再起動スケジュール設定

Linuxサーバーの再起動スケジュール化のご紹介です。

非常に簡単で安定していますのでご検討中の方は参考にしてください。
私もこの設定を入れていますが、再起動が失敗したことはありません。

手順1:再起動シェルスクリプトの作成

 
usr/bin の直下にreboot.shを作成してください
再起動コマンドです。

手順2:スケジュール設定

 
etcの直下にcrontabというファイルがありますので、記載済のコメントアウトに従って再起動日時を指定します。
crontabに下記を追記すればOK

例1:毎週月曜日のAM3時1分に再起動
1 3 * * mon root sh /usr/bin/reboot.sh

例2:毎月1日のAM3時1分に再起動
1 3 * 1 * root sh /usr/bin/reboot.sh

例3:毎日AM3時1分に再起動
1 3 * * * root sh /usr/bin/reboot.sh

※reboot.shを違うシェルスクリプトにすれば応用可能です。

再起動されている事の確認

 
下記コマンドを実行してください。
再起動した時間が出力されます。

reboot system boot 2.6.xx.el6.i Mon May 9 03:03 – 14:27 (11:23)
reboot system boot 2.6.xx.el6.i Mon May 2 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Apr 25 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Apr 18 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Apr 11 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Apr 4 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Mar 28 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Mar 21 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Mar 14 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Mar 7 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Feb 29 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Feb 22 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Feb 15 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Feb 8 03:03 – 03:01 (6+23:57)
reboot system boot 2.6.xx.el6.i Mon Feb 1 03:03 – 03:01 (6+23:57)

コメント

コメントする

目次