2. 批量kill-pid
1.code
#!/bin/bash
cd /home/makexu/env/fasttext/bin
source activate
flag=$1
echo ${flag}
function chat_notify_fasttext()
{
echo "begin restart chat_notify_fasttext"
timeout 300s supervisorctl stop gxx_chat_notify_fasttext
for pid in $(ps -ef f | grep -w 'gxx_fasttext' | grep -w 'chat_notify.py' | grep -v grep | awk '{print $2}'); do
echo ${pid}
kill -9 ${pid}
done
timeout 300s supervisorctl start gxx_chat_notify_fasttext
echo "end restart chat_notify_fasttext"
}
function chat_notify_fasttext_2()
{
echo "begin restart chat_notify_fasttext_2"
timeout 300s supervisorctl stop gxx_chat_notify_fasttext_2
for pid in $(ps -ef f | grep -w 'gxx_fasttext_2' | grep -w 'chat_notify_2.py' | grep -v grep | awk '{print $2}'); do
echo ${pid}
kill -9 ${pid}
done
timeout 300s supervisorctl start gxx_chat_notify_fasttext_2
echo "end restart chat_notify_fasttext_2"
}
if [ "${flag}" == "gxx_chat_notify_fasttext" ];then
echo "restart gxx_chat_notify_fasttext"
chat_notify_fasttext
elif [ "${flag}" == "gxx_chat_notify_fasttext_2" ];then
echo "restart gxx_chat_notify_fasttext_2"
chat_notify_fasttext_2
else
echo "restart all"
chat_notify_fasttext
chat_notify_fasttext_2
fi
lsof -n | grep makexu | grep deleted | grep 'django-1.11' | awk '{print $2}' | grep -v 7862 |xargs kill -9
http://www.cnblogs.com/makexu/

浙公网安备 33010602011771号