运维网's Archiver
论坛
›
Python
› python获取程序PID并写入文件
喜旎果
发表于 2017-5-1 15:16:17
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
页:
[1]
查看完整版本:
python获取程序PID并写入文件