python中定时执行脚本
import time, os, sched
def ll(num):
print('123123456')
with open('tt.txt', 'ab') as txt:
txt.write(('2222222222222222222' + str(num)).encode())
txt.write('\n'.encode())
def perform_command(cmd, inc, num):
schedule.enter(inc, 0, perform_command, {cmd, inc, num})
'''enter之后可带的参数意义:delay, priority, action, argument=()
# delay表示执行周期,也就是多久之后开始执行
# priority表示执行优先等级,1~10的优先级排序,1为最先执行者
# action执行的函数名
# argument表示函数带的参数,以{}形式封装'''
ll(num)
os.system(cmd)
def timming_exe(cmd, inc, num):
schedule.enter(inc, 0, perform_command, {cmd, inc, num})
schedule.run()
schedule = sched.scheduler(time.time, time.sleep)
timming_exe("echo %time%", 10, 99)