pid内容为进程号
ps -ef|grep hadoop 出现PID A,B,C 可能误杀B,C
[hadoop@hadoop000 sbin]$ cat hadoop-daemon.sh |grep pid
#HADOOPPIDDIR The pid files are stored. /tmp by default.
pid=$HADOOP_PID_DIR/hadoop-$HADOOP_IDENT_STRING-$command.pid
if [ -f $pid ]; then
if kill -0 cat $pid
> /dev/null 2>&1; then
echo $command running as process cat $pid
. Stop it first.
echo $! > $pid
if [ -f $pid ]; then
TARGET_PID=cat $pid
rm -f $pid
官方给的sh脚本中,也是通过读取pid文件内容作为进程kill对象
我们直接对pid文件的数字就是我们对于的进程pid
[hadoop@hadoop01 tmp]$ ls *.pid
hadoop-hadoop-datanode.pid yarn-hadoop-nodemanager.pid
hadoop-hadoop-namenode.pid yarn-hadoop-resourcemanager.pid
hadoop-hadoop-secondarynamenode.pid yarn-hdfs-resourcemanager.pid
[hadoop@hadoop01 tmp]$
[hadoop@hadoop01 tmp]$ cat hadoop-hadoop-datanode.pid
8990
[hadoop@hadoop01 tmp]$ jps
12060 Jps
9193 SecondaryNameNode
9566 NodeManager
8990 DataNode
9450 ResourceManager
kill -0 cat /tmp/hadoop-hadoop-datanode.pid
---shell常用kill pid方式`
原文地址:http://blog.51cto.com/chaorenyong/2118730