每五秒循环执行此python文件
import datetime
import threading
def
func():
with
open('/home/ubuntu/test.log','a+')as f
:
f
.write('hhhhhhhhh'+'\n')
timer
= threading
.Timer(5, func
)
timer
.start()
#定时器
,参数为
(多少时间后执行,单位为秒,执行的方法
)
timer
= threading
.Timer(5, func
)
timer
.start()
将放在linux服务器上的python文件,为了让其在中断后,如flask的api接口,关闭后就不能访问,为了改善这样的行为使用 nohup python -u ./python.py > cmd.log &
转载请注明原文地址: https://yun.8miu.com/read-54232.html