get pid(process id)

$ ps -ef | grep python

501 922 870 0 8:15PM ttys000 0:00.07 python $ python

>>> import os

>>> print os.getpid()

922 <- 해당 Python의 PID값

>>> import psutil

>> psutil.Process(os.getpid()).ppid()

870 <- 해당 Python의 Parent PID값

출처: https://info-lab.tistory.com/110 [:: IT School ::]

Leave a Reply

Your email address will not be published. Required fields are marked *