【发布时间】:2014-06-29 14:27:45
【问题描述】:
当我有进程ID时,我想获取进程名称(而不是整个进程信息)。我需要的命令应该只返回进程名称。
【问题讨论】:
标签: shell unix process command
当我有进程ID时,我想获取进程名称(而不是整个进程信息)。我需要的命令应该只返回进程名称。
【问题讨论】:
标签: shell unix process command
你可以试试
ps --pid <pid> -o cmd h
在哪里
--pid <pid> specifies the process' PID
-o cmd tells ps to only print the command name
h suppresses headers
如果您想要 命令及其所有参数;或
ps --pid <pid> -o comm h
如果您想要只需要可执行文件名。
【讨论】:
如果您的系统使用 /proc 文件系统:
cut -d "" -f 1 /proc/$pid/cmdline
【讨论】: