#!/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
原文:http://www.cnblogs.com/vagabond/p/4996331.html