美文网首页Python
python --定时任务

python --定时任务

作者: 吉祥鸟hu | 来源:发表于2020-10-09 10:38 被阅读0次

from apscheduler.schedulers.blocking import BlockingScheduler
import time
from datetime import datetime
from apscheduler.triggers.cron import CronTrigger
def schedule_task():
    """
    create one schedule visitor
    :return:
    """
    print("dsds")
    time.sleep(4)
    print("current time is: %s" % datetime.now())
def schedule_task1():
    """
    create one schedule visitor
    :return:
    """
    print("jixn")
    time.sleep(4)
    print("current jixn time is: %s" % datetime.now())
if __name__ == '__main__':
    schedule_job = BlockingScheduler()
    # schedule_job.add_job(job_function, 'cron', hour=3, minute=30)
    schedule_job.add_job(schedule_task, 'cron',second = '*/5')
    schedule_job.add_job(schedule_task1, 'cron',second = '*/3')
    schedule_job.start()
    print(CronTrigger.from_crontab('37 * * *  *'))


本文由博客群发一文多发等运营工具平台 OpenWrite 发布

相关文章

网友评论

    本文标题:python --定时任务

    本文链接:https://www.haomeiwen.com/subject/zeflpktx.html