【问题标题】:How to find the PID of a running command in cmd/powershell over SSH?如何通过 SSH 在 cmd/powershell 中查找正在运行的命令的 PID?
【发布时间】:2022-01-06 13:32:20
【问题描述】:

类似于 echo $$; python my_script.py > out.log

预期输出:

使用 cmd_command 或 powershell 命令

【问题讨论】:

  • 对于PID使用$PID自动变量。
  • @Hazrelle,谢谢,windows 需要类似的东西
  • 您可以使用Get-Process,但您需要知道显示窗口的进程的名称。
  • 请澄清您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: windows powershell cmd pid


【解决方案1】:

如果您正在运行 PowerShell,则 PID 变量可用。

PS C:\> $PID
8420
PS C:\> Get-CimInstance -Class CIM_Process | Where-Object { $_.ProcessId -eq $PID }

ProcessId Name     HandleCount WorkingSetSize VirtualSize
--------- ----     ----------- -------------- -----------
8420      pwsh.exe 1004        119939072      2204255981568

查看其他可用的成员:

Get-CimInstance -Class CIM_Process | Where-Object { $_.ProcessId -eq $PID } | Format-List -Property * -Force

Get-CimInstance -Class CIM_Process | Get-Member

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-27
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    • 2013-05-08
    • 2011-09-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多