linux进程监控,monitor脚本
由于服务器上一些进程莫名的挂掉,需要些一个monitor的bash脚本来监控这些进程:
#! /bin/bash #chkconfig info ### BEGIN INIT INFO # Provides: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Description: ### END INIT INFO MYSQL_NAME='mysql' APACHE_NAME='http' function check_process { search_string=$1 search_result=`nmap localhost|grep -P $1'$'|awk '{print $3}'|grep $search_string` echo $search_result if [ "$search_result" = "$search_string" ] then echo $"Still exist!" else echo $"Not exist!" /opt/lampp/lampp start >> /dev/null echo $"Lampp restart!" echo $"Lampp stop unexpectedly, now it restart by cron!" | mail -s "Breamweb error!" [email protected] fi } case "$1" in start) /opt/lampp/lampp start ;; stop) /opt/lampp/lampp stop ;; monitor) check_process $MYSQL_NAME check_process $APACHE_NAME ;; esac exit 0
crontab:
*/1****/etc/init.d/<script_name>monitor>>/var/log/cron.<script_name>.monitor.log2>&1
完
相关推荐
linuxwcj 2020-10-21
彼岸随笔 2020-10-20
yutou0 2020-10-17
jarrygao 2020-11-02
shipinsky 2020-09-23
touchfuture 2020-09-16
hongsheyoumo 2020-09-04
momoku 2020-09-11
ruancw 2020-08-27
TuxedoLinux 2020-08-18
vvu 2020-08-16
downtown 2020-08-11
luvzhan 2020-07-28
maxelliot 2020-06-28
cuixingwudi 2020-06-25
linuxdashencom 2020-06-21
旭灿 2020-06-16
wenjieyatou 2020-06-14