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. jdk10配置

    解压 vi /etc/profile JAVA_HOME=/home/elasticsearch/jdk- CLASSPATH=$JAVA_HOME/lib/ PATH=$PATH:$JAVA_HOM ...

  2. Redis在Windows环境下单机安装及远程访问方案

    一.下载Windows版Redis 打开https://github.com/MicrosoftArchive/redis/tags地址,找到最新版Redis安装包(Redis-x64-3.2.100 ...

  3. Kafka高可用实现

    数据存储格式 Kafka的高可靠性的保障来源于其健壮的副本(replication)策略.一个Topic可以分成多个Partition,而一个Partition物理上由多个Segment组成. Seg ...

  4. C#:文件/注册表/线程的操作

    文件的操作:(file与fileinfo,前者是静态方法,执行安全检查,适合对一个的操作) 1.1.create: using System; using System.Collections.Gen ...

  5. MVC如何设置启动页

    1.解决方案下的项目,右键,属性,Web,特定页,切换下其他选项以保存

  6. 51nod 1376 最长上升子序列的数量 | DP | vector怒刷存在感!

    51nod 1376 最长上升子序列的数量 题解 我们设lis[i]为以位置i结尾的最长上升子序列长度,dp[i]为以位置i结尾的最长上升子序列数量. 显然,dp[i]要从前面的一些位置(设为位置j) ...

  7. UVA10498 Happiness 【单纯形】

    题目链接 UVA10498 题解 模板题 #include<algorithm> #include<iostream> #include<cstdlib> #inc ...

  8. BZOJ3688 折线统计 【dp + BIT】

    题目链接 BZOJ3688 题解 将点排序 设\(f[i][j][0|1]\)表示以第\(i\)点结尾,有\(j\)段,最后一段上升或者下降的方案数 以上升为例 \[f[i][j][0] = \sum ...

  9. 洛谷 P4244 [SHOI2008]仙人掌图 II 解题报告

    P4244 [SHOI2008]仙人掌图 II 题目背景 题目这个II是和SHOI2006的仙人掌图区分的,bzoj没有. 但是实际上还是和bzoj1023是一个题目的. 题目描述 如果某个无向连通图 ...

  10. Android studio gradle配置完整版(转)

    Android studio gradle配置完整版https://my.oschina.net/u/1471093/blog/539075 Android studio 自定义打包apk名 - pe ...