import time import logging from xls2table import run_htp from apscheduler.schedulers.blocking import BlockingScheduler def attendance_job(): print('Apscheduler Runtime: '+time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) FMT = '%(asctime)s %(filename)s %(funcName)s %(levelname)s %(message)s' logging.basicConfig(format=FMT, level=logging.INFO) run_htp(url='http://192.168.80.3:8069', dbname='htp', dburl='postgresql://odoo:odootyughj@192.168.80.3:5432/htp') #sched = BlockingScheduler() sched = BlockingScheduler(daemon=True) #sched.add_job(attendance_job, 'interval', seconds=5) #sched.add_job(attendance_job, 'cron', hour=23, minute=30, timezone='Asia/Taipei') sched.add_job(attendance_job, 'cron', hour=8, minute=35, timezone='Asia/Taipei') #sched.add_job(attendance_job, 'cron', hour=18, minute=10, timezone='Asia/Taipei') try: sched.start() except (KeyboardInterrupt, SystemExit): sched.shutdown()