python获取程序PID并写入文件

运行python的时候将程序PID写入文件,以方便kill程序。

 

 

import os

def writePid():
    pid = str(os.getpid())
    f = open('athena.pid', 'w')
    f.write(pid)
    f.close()
 

 

 

参考:

http://neopatel.blogspot.com/2010/09/python-adding-pid-file.html

 

-- end

你可能感兴趣的:(python)