#!/bin/bash while true do #判断pid是否存在 pid=`ps -ef |grep "man"|grep -v grep` if [ $? -ne 0 ];then cd /data/weilubo /usr/bin/nohup sh ./man & # echo "server man restart" timestanp=`date ‘+%Y-%m-%d %H:%M:%S‘` echo "$timestanp - man 重启,请查看/var/log/syslog" >>/data/weilubo/logs-sewise_man.log sleep 5 else # echo "man is normal" sleep 10 fi done #注:脚本文件的命名不能包含man
#
chmod +x scriptname.sh
#
1. nohup ./scriptname.sh >/data/logs-scriptnamemonitor 2>&1 & #自定义nohup.out的日志路径 2. nohup ./scriptname.sh & 3. >/dev/null 2&1
时间: 2024-11-10 01:10:10