python 프로세스 목록 얻기, 숫자세기

less than 1 minute read

파이썬으로 멀티스레드 대신 OS에 프로세스를 돌리는 프로그램을 만들게 된다면… 쓰게되는 코드

#리눅스에서 실행중인 프로세스 목록 프린트하기 from subprocess import Popen, PIPE for line in Popen([‘ps’, ‘aux’], shell=False, stdout=PIPE).stdout: print line

import os data = [(int(p), c) for p, c in [x.rstrip(‘\n’).split(‘ ‘, 1)
for x in os.popen(‘ps h -eo pid:1,command’)]]

http://andreinc.net/2010/11/07/how-to-get-the-active-process-list-on-a-linux-machine-using-python/

http://stackoverflow.com/questions/1091327/processlist

http://stackoverflow.com/questions/884650/how-to-spawn-parallel-child-processes-on-a-multi-processor-system

http://www.linux.co.kr/home/lecture/index.php?cateNo=&secNo=&theNo=&leccode=214

http://www.seobangnim.com/zbxe/?document_srl=836

나중에 정리해놔야지 라고 하지만…언제할지…