很多时候写脚本或者杀进程的时候需要获取进程的pid,以下方式为工作中的小技巧
方式一:
ps -C 进程命令 -o pid=
[root@localhost ~]# ps -C dhclient -o pid=
2322
方式二
ps -ef |grep elas|grep -v grep |awk '{print $2}'|sed -n 1p
很多时候写脚本或者杀进程的时候需要获取进程的pid,以下方式为工作中的小技巧
方式一:
ps -C 进程命令 -o pid=
[root@localhost ~]# ps -C dhclient -o pid=
2322
方式二
ps -ef |grep elas|grep -v grep |awk '{print $2}'|sed -n 1p