“kill -9”一时爽,秋后算账泪两行

2022-11-08,

接受两个参数。第一个参数是pid,第二个参数是等待的秒数。

#!/bin/bash

# 接受两个参数。第一个参数是pid,第二个参数是等待的秒数。

pid=$1
count=$2
n=0
if [ ! -n $count ];then
count=10
fi while [[ $n -lt $count ]]
do
let "n++"
kill -0 $pid
if [ $? -ne 0 ]
then
echo "program not exist"
break
else
echo "send kill -15 to $pid"
kill -15 $pid
sleep 1
fi if [[ $n -eq $count ]]
then
echo "kill -9 $pid"
# after 10s , try to send kill -9
kill -9 $pid
fi
done

“kill -9”一时爽,秋后算账泪两行的相关教程结束。

《“kill -9”一时爽,秋后算账泪两行.doc》

下载本文的Word格式文档,以方便收藏与打印。