apscheduler.triggers.interval

API

Trigger alias for add_job(): interval

class apscheduler.triggers.interval.IntervalTrigger(weeks=0, days=0, hours=0, minutes=0, seconds=0, start_date=None, end_date=None, timezone=None)

Bases: apscheduler.triggers.base.BaseTrigger

Triggers on specified intervals, starting on start_date if specified, datetime.now() + interval otherwise.

Parameters:
  • weeks (int) – number of weeks to wait
  • days (int) – number of days to wait
  • hours (int) – number of hours to wait
  • minutes (int) – number of minutes to wait
  • seconds (int) – number of seconds to wait
  • start_date (datetime|str) – starting point for the interval calculation
  • end_date (datetime|str) – latest possible date/time to trigger on
  • timezone (datetime.tzinfo|str) – time zone to use for the date/time calculations

Introduction

This method schedules jobs to be run periodically, on selected intervals.

You can also specify the starting date and ending dates for the schedule through the start_date and end_date parameters, respectively. They can be given as a date/datetime object or text (in the ISO 8601 format).

If the start date is in the past, the trigger will not fire many times retroactively but instead calculates the next run time from the current time, based on the past start time.

Examples

from datetime import datetime

from apscheduler.scheduler import BlockingScheduler

def job_function():
print("Hello World") sched = BlockingScheduler() # Schedule job_function to be called every two hours
sched.add_job(job_function, 'interval', hours=2) sched.start()

You can use start_date and end_date to limit the total time in which the schedule runs:

# The same as before, but starts on 2010-10-10 at 9:30 and stops on 2014-06-15 at 11:00
sched.add_job(job_function, 'interval', hours=2, start_date='2010-10-10 09:30', end_date='2014-06-15 11:00)

The scheduled_job() decorator works nicely too:

from apscheduler.scheduler import BlockingScheduler

@sched.scheduled_job('interval', id='my_job_id', hours=2)
def job_function():
print("Hello World")

APScheduler API -- apscheduler.triggers.interval的更多相关文章

  1. APScheduler API -- apscheduler.triggers.date

    apscheduler.triggers.date API Trigger alias for add_job(): date class apscheduler.triggers.date.Date ...

  2. APScheduler API -- apscheduler.triggers.cron

    apscheduler.triggers.cron API Trigger alias for add_job(): cron class apscheduler.triggers.cron.Cron ...

  3. APScheduler API -- apscheduler.schedulers.base

    apscheduler.schedulers.base API class apscheduler.schedulers.base.BaseScheduler(gconfig={}, **option ...

  4. Python 定时任务框架 APScheduler 详解

    APScheduler 最近想写个任务调度程序,于是研究了下 Python 中的任务调度工具,比较有名的是:Celery,RQ,APScheduler. Celery:非常强大的分布式任务调度框架 R ...

  5. python APScheduler模块

    简介 一般来说Celery是python可以执行定时任务, 但是不支持动态添加定时任务 (Django有插件可以动态添加), 而且对于不需要Celery的项目, 就会让项目变得过重. APSchedu ...

  6. apscheduler 绿色版

    由于依赖EntryPoint,因此apscheduler在离线的方式(直接拷贝然后引用)使用时,会报错. 错误信息类似: No trigger by the name “interval/cron/d ...

  7. 用apscheduler处理调度任务,定时任务,重复任务

    from apscheduler.schedulers.blocking import BlockingScheduler from apscheduler.triggers.cron import ...

  8. APScheduler 浅析

    前言 APScheduler是python下的任务调度框架,全程为Advanced Python Scheduler,是一款轻量级的Python任务调度框架.它允许你像Linux下的Crontab那样 ...

  9. python定时任务APScheduler

    APScheduler定时任务 APScheduler 支持三种调度任务:固定时间间隔,固定时间点(日期),Linux 下的 Crontab 命令.同时,它还支持异步执行.后台执行调度任务. 一.基本 ...

随机推荐

  1. php in_array()优化

    开年首篇文章,后天上班了,正在调整状态.年前室友问我一段程序效率问题,刚好来研究下!该函数是关于判断域名字符串是否是单拼域名.双拼域名.三拼域名...多拼域名问题: //原始程序function pi ...

  2. UESTC 1832

    今天比赛的时候做的一个题目.感觉这个题目不错. 题目描述: Description In a laboratory, an assistant, Nathan Wada, is measuring w ...

  3. 【About Me】 — 有关于我的 —

    HNSDFZ信息组一直非常蒻的一只蒟蒻,正在朝着大佬与正解的方向不懈努力中. 目前还是一只高一的萌新,下个学期进高二就可以升级当学姐啦……٩(๑>◡<๑)۶  呜呜呜已经高二啦!现在高二了 ...

  4. 【BZOJ2731】三角形覆盖问题

    想象一条平行于\(y\)轴的扫描线,从低往高扫描.如何确定关键高度才能使每两个关键高度之间分割出的图形易于计算呢? 关键高度有:三角形底边高度.三角形上顶点高度.三角形交点的高度. ​ 如此分割,我们 ...

  5. 解题:HEOI 2012 采花

    题面 题外话:LYD说他当时看错题了,考场爆零了,然后有了作诗这道题=.= 离线处理询问,按右端点递增排序,然后对于每种花$flw[i]$,我们求一个$pre[flw[i]]$表示这种花上一次出现的位 ...

  6. SenseTime Ace Coder Challenge 暨 商汤在线编程挑战赛 E. 疯狂计数

    1.改高精度 :float/double的精度为x位,小数部分最多x+x位(乘法和加法),整数部分<1000000*1000000/2=5 * 10^11 2.分成整数部分和小数部分分别存储,貌 ...

  7. 人人贷网的数据爬取(利用python包selenium)

    记得之前应同学之情,帮忙爬取人人贷网的借贷人信息,综合网上各种相关资料,改善一下别人代码,并能实现数据代码爬取,具体请看我之前的博客:http://www.cnblogs.com/Yiutto/p/5 ...

  8. Linux运维三:系统目录结构

    Linux系统目录结构官方参考:http://www.pathname.com/fhs/ 1:Linux树状目录结构图 下面目录中标红的是必须要掌握的! 2:根目录  目录 描述 / 第一层次结构的根 ...

  9. 「Vue」过滤器

    #全局过滤器要写在var vue之前<td>{{item.time | ctime }}</td>Vue.filter('ctime'(过滤器名),function(data( ...

  10. Mac下Clang编译libcurl

    使用终端进入curl的根目录下,执行 ./configre CC=clang make make install 之后前往/usr/local/lib下生成了libcurl.a和相应的动态库,头文件在 ...