【Linux】 删除过滤出来的某些进程 kill -9

stop.sh

#!/bin/bash
PID=$(ps -ef | grep python | grep -v grep | awk '{ print $2 }')
if [ -z "${PID}" ]
then
        echo Application is already stopped
else
        echo kill ${PID}
        kill -9 ${PID}
fi

简化版

kill -9 $(ps -ef | grep python | grep -v grep | awk '{ print $2 }')

你可能感兴趣的:(linux,运维,linux,运维,服务器)