1. 程式人生 > >抓取apache2的進程pid

抓取apache2的進程pid

pid

抓取apache2的進程pid:

vi a1.py

#!/usr/bin/python

import os

http = os.popen(‘netstat -ntpl | grep -w 80‘,‘r‘).readlines()
str1 = ‘‘.join(http)
pid = str1.split()[6].strip(‘/apache2‘)
print pid
:wq

python a1.py

抓取apache2的進程pid