̃Gg[͂ĂȃubN}[Nɒlj

apache の自動再起動と死活監視



cron による apache(httpd) の再起動と死活監視。
もし httpd プロセスが存在しない場合は、httpd を起動する。


  • cron ファイル
/etc/cron.d/root.cron


  • 毎朝 5 時に httpd を再起動する
#
# httpd restart
#
0 5 * * * root /etc/init.d/httpd restart


  • httpd プロセスが存在しない場合、httpd を起動する(毎時 5 分の確認)
    • その場合、メールでも通知する
#
# httpd start if process not found
#
5 * * * * root ps ax | grep -v grep | grep -q httpd || ( /etc/init.d/httpd start && mail -s 'httpd start' hoge@example.com )





server/apache/etc/restart_and_process_check.txt