Dup Goto 📝

PsUtil

PT2/lang/python/old-notes 10-17 14:11:30
To Pop
15 lines, 69 words, 493 chars Tuesday 2023-10-17 14:11:30

This is a simple cheat sheet, only containing stuff I've used before. See https://psutil.readthedocs.io/en/latest/ for full docs {{c import psutil

print(psutil.pids()) # get list of pids

this is the preferred method for iterating over pids

(i.e. don't iterate over the list returned by psutil.pids() )

for proc in psutil.process_iter():

proc is a psutil.Process

(note pid is an attribute, not a method)

proc.pid proc.name() proc.cmdline() }}%TIME=1618874233