用来计算2个时间的时间差。
调用的时间建议采用挂载的方式,即:
nohup python -u xxx.py > nohup.test.log 2>&1 &
import time
import os
a = 1650380930.2743425
'''
1. time.time()生成
2. time.mktime(time.strptime("2022-04-20 07:33:00","%Y-%m-%d %H:%M:%S")) 特定时间生成
'''
last_hours= -1
last_minutes= -1
last_seconds = -1
while True:
b = time.time()
dist = b-a
minutes, seconds = divmod(dist, 60)
hours, minutes = divmod(minutes, 60)
if minutes != last_minutes:
print ('hours = ', hours, ' , minutes = ', minutes )
last_minutes = minutes
if hours > 3:
data = os.popen('./test.sh')
print (data.read())
break