#!/bin/bash source /etc/rc.d/init.d/functions #pring info print_info() { if [ $1 = 0 ] ; then action "$2" /bin/true else action "$2" /bin/false exit $3 fi } #run a process $1 times run_process() { i=0; while [ $i -lt $1 ] do echo "run process:$2"; echo $2 | bash; let "i=$i+1"; done } #kill process once kill_process() { local_kill_cmd="ps -A -o pid,stime,comm,cmd | grep \"$1\" | grep -v grep"; #按照pid大小排序 for pid_num in `echo $local_kill_cmd | bash | awk '{print $1}' | sort -n`; do pid_name=`echo $local_kill_cmd | bash | grep "$pid_num" | awk '{print $3}'`; echo "kill $pid_num ==> $pid_name"; kill -9 $pid_num >/dev/null 2>&1; print_info $? "stop $pid_name" 1; done }
shell之gfun.sh
猜你喜欢
转载自andylin02.iteye.com/blog/829483
今日推荐
周排行