根据pid定位文件

Linux 根据进程获取文件路径

在Linux 底下,使用 top 命令可以监控系统的进程情况,但是很多时候,我们需要根据进程的PID来找到对应的文件路径,例如图中的 29310 这个进程,如何知道 httpd 这个进程的文件路径呢?

ls -l /proc/29310/cwd    列出29310 就是httpd 这个进程的工作目录

ls -l /proce/29310/exe    列出29310 这个进程的文件路径

pwdx 29310    可以直接获得该进程的工作目录

Windows 根据进程获取文件路径

其实很简单,在命令行下,输入 wmic ,然后输入 process 即可

还可以根据条件来筛选

wmic process where "caption='editplus.exe'" get commandline

这句的意思是,先获取所有进程列表,然后从中筛选出 caption 为 editplus.exe 的进程信息,最后从这条进程信息中,提取 commandline 字段来显示

其中,where中可以用的字段有以下所示,可以根据具体情况来应用了

Caption
CommandLine
CreationClassName
CreationDate
CSCreationClassName
CSName
Description
ExecutablePath
ExecutionState
Handle
HandleCount
InstallDate
KernelModeTime
MaximumWorkingSetSize
MinimumWorkingSetSize
Name
OSCreationClassName
OSName
OtherOperationCount
OtherTransferCount
PageFaults
PageFileUsage
ParentProcessId
PeakPageFileUsage
PeakVirtualSize
PeakWorkingSetSize
Priority
PrivatePageCount
ProcessId
QuotaNonPagedPoolUsage
QuotaPagedPoolUsage
QuotaPeakNonPagedPoolUsage
QuotaPeakPagedPoolUsage
ReadOperationCount
ReadTransferCount
SessionId
Status
TerminationDate
ThreadCount
UserModeTime
VirtualSize
WindowsVersion
WorkingSetSize
WriteOperationCount
WriteTransferCount 

版权所有:《太阳花工作室》 => 《根据pid定位文件
本文地址:http://bg.artuion.com/win_lin_mac/44.html
除非注明,文章均为 《太阳花工作室》 原创,欢迎转载!转载请注明本文地址,谢谢。