## 再起動関連変数定義
#httpd_syntaxcheck=`httpd -t 2>&1`
#httpd_status=`/etc/init.d/httpd status`
#httpd_process=`pgrep httpd | wc -l`
#echo "$httpd_syntaxcheck"
#echo "$httpd_status"
#1.Apacheの設定ファイルシンタックスチェック(NGだったら再起動を行わずエラーを通知する)
if [ "$httpd_syntaxcheck" = "Syntax OK" ]; then
echo "`date` SyntaxCheck OK" >> $LOGFILE
else
subject="$(basename $0 .sh) $(hostname) failed"
Mail_Send "$from" "$to" "$cc" "$subject_err" "$httpd_syntaxcheck_err"
fi
#2.Apacheを停止(起動スクリプトでOK) 停止に失敗したらエラー通知
#3.Apacheのプロセスが完全に無くなったことを確認(pgrepでOK)
/etc/init.d/httpd stop
#httpd_process=`pgrep httpd | wc -l`
if [ "$httpd_process" = 0 ]; then
echo "`date` httpd stop" >> $LOGFILE
else
#NGであればエラーを通知
subject="$(basename $0 .sh) $(hostname) failed"
Mail_Send "$from" "$to" "$cc" "$subject_err" "$httpd_stop_err"
fi
#4.Apacheの起動(起動に失敗したらエラー通知)
#5.Apacheが起動していないことを確認してから起動
if [ "$httpd_status" = "httpd is stopped" ]; then
/etc/init.d/httpd start
else
subject="$(basename $0 .sh) $(hostname) failed"
Mail_Send "$from" "$to" "$cc" "$subject_err" "$httpd_start_err"
fi
長らく放置しており、すみませんでした。
結局上記のようなスクリプトになりました。