LoginSignup
3
3

More than 5 years have passed since last update.

httpd等のプロセスdown時の自動再起動設定をする(cronを使う編)

Last updated at Posted at 2016-02-17

いろいろなやり方は有ると思いますが、
何かの拍子にプロセスが落ちた、
もしくはアタック食らってプロセスが落ちた、
異論はあるでしょうが、とりあえずサービスダウンを短くしたい、
個人のプライベートサイトでオペレーションするの怠いのでとりあえず動いていてくれれば良いな人向け。

検証環境

・CentOS6

入れる

cronで1分間でpidofを使いプロセスの生き死を見て死んでたらrestartする仕組み
restartついでにメールも飛ばす感じに
*秒間でcronまわす方法とかあるけど1分くらいよかろう
*restartで変にコケた場合等はまともに動かないかもしれないので違う方法も視野に
*あと監視も入れておきましょう

cron
* * * * * root /sbin/pidof httpd > /dev/null 2>&1 || (/etc/init.d/httpd restart && echo "httpd restarted." | mail -s "Process Restartttt!!!" hogehoge@hogehoge.com > /dev/null 2>&1)
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3