首页 / 操作系统 / Linux / Shell应用:批量kill进程
Shell应用:批量kill进程事例程序:
[plain] - #!/bin/bash
-
- if test -z $1; then
- echo "Usage: batch_kill_process.sh param"
- exit 0
- fi
-
- param=$1
-
- ps aux | grep "$1" | grep -v "grep" | grep -v "batch_kill_process.sh"
-
- echo "do you want to kill all (y/n)? "
-
- read $param
-
- if test $param="y"; then
- ps aux | grep "$1" | grep -v "grep" | grep -v "batch_kill_process.sh" | awk "{print $2}" | xargs -i kill -9 {}
- fi
-
- exit 0