根据进程名查看该进程的创建时间

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/python
#_*_encoding:utf-8_*_
#print the process create time by the process name .
import psutil,datetime,sys
if sys.argv[1] == "-h":
	print "Usage:%s -h|httpd|nginx|mysqld|and so on" % sys.argv[0]
	print "例如:python processt.py httpd #查看httpd进程创建的时间戳。"
	exit()
def processt(name,):
	pid = psutil.pids()
	for i in pid:
		pn = psutil.Process(i)	
		if pn.name() == name:
			 R = datetime.datetime.fromtimestamp(psutil.Process(i).create_time()).strftime("%y-%m-%d;%H:%M:%S")
	print name + "'s create time is : " + R
processt(sys.argv[1])