Python Library Task
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

crontab.py 552B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. # -*- coding: UTF-8 -*-
  3. import sys
  4. sys.path.append('../..')
  5. import task
  6. import time
  7. def print_localtime(cj):
  8. print(time.localtime())
  9. ct = task.crontab(accuracy=7)
  10. minute = int(time.strftime('%M'))
  11. ct.add_cronjob([minute + 1, minute + 3], task.crontab.ANY, task.crontab.ANY, task.crontab.ANY, task.crontab.ANY, print_localtime)
  12. print('Cronjob added for Minute: %02d, %02d\n--------------------------------\n' % (minute + 1, minute + 3))
  13. ct.run()
  14. try:
  15. time.sleep(195)
  16. ct.stop()
  17. ct.join()
  18. finally:
  19. ct.stop()