task/_examples_/crontab.py

25 lines
552 B
Python

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
sys.path.append('../..')
import task
import time
def print_localtime(cj):
print(time.localtime())
ct = task.crontab(accuracy=7)
minute = int(time.strftime('%M'))
ct.add_cronjob([minute + 1, minute + 3], task.crontab.ANY, task.crontab.ANY, task.crontab.ANY, task.crontab.ANY, print_localtime)
print('Cronjob added for Minute: %02d, %02d\n--------------------------------\n' % (minute + 1, minute + 3))
ct.run()
try:
time.sleep(195)
ct.stop()
ct.join()
finally:
ct.stop()