#!/bin/bash fun(){ ps -ef | grep "$1" | awk '{print $2 $8}' > /usr/file while read line ;do if [[ $line == $1 ]] then # do something // return fi done < /usr/file echo "shutdown ... after 3s " sleep 3 shutdown -h now } while true ; do var=`date +%s` sleep 1 if [[ $((var%5)) -eq 0 ]] then fun $1 fi done
// 每过五秒钟去检查一次是否该进程号是否存在? 不存在则shutdow ;;
// 保存在/sbin/目录下; 并将权限改为 500 ;;
// ln -s /sbin/shut.sh /sbin/shut