Linux 根据进程 pid 获取 进程名
原创
©著作权归作者所有:来自51CTO博客作者岳麓丹枫的原创作品,请联系作者获取转载授权,否则将追究法律责任
根据进程名获取进程 PID
[root@VM-0-12-centos ~]# ps -ef | grep postmaster | grep -v grep
postgres 1025 1 0 Oct02 ? 00:00:25 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/
[root@VM-0-12-centos ~]#
根据进程 PID 获取进程名
[root@VM-0-12-centos ~]# ps -p 1025
PID TTY TIME CMD
1025 ? 00:00:25 postmaster
[root@VM-0-12-centos ~]#
[root@VM-0-12-centos ~]# ps -p 1025 -o comm=
postmaster
[root@VM-0-12-centos ~]#