#!/usr/bin/python3
import sys
import datetime
import os
import time
if __name__ == '__main__':
while 1:
startTime=datetime.datetime.now()
main_path='./
main.py'
py=sys.executable
status=os.system(r'{} {} {} {}'.format(py, main_path, sys.argv[1],sys.argv[2]))
if status==0:
time.sleep(120)
else:
endTime=datetime.datetime.now()
if endTime-startTime>60*60:
break
我现在在程序里启一个脚本,我想判断这个脚本运行了超过 1 个小时就 kill 掉,如何写?