apscheduler.triggers.date

API

Trigger alias for add_job(): date

class apscheduler.triggers.date.DateTrigger(run_date=None, timezone=None)

Bases: apscheduler.triggers.base.BaseTrigger

Triggers once on the given datetime. If run_date is left empty, current time is used.

Parameters:
  • run_date (datetime|str) – the date/time to run the job at
  • timezone (datetime.tzinfo|str) – time zone for run_date if it doesn’t have one already

Introduction

This is the simplest possible method of scheduling a job. It schedules a job to be executed once at the specified time. It is APScheduler’s equivalent to the UNIX “at” command.

The run_date can be given either as a date/datetime object or text (in the ISO 8601 format).

Examples

from datetime import date

from apscheduler.scheduler import BlockingScheduler

sched = BlockingScheduler()

def my_job(text):
print(text) # The job will be executed on November 6th, 2009
sched.add_job(my_job, 'date', run_date=date(2009, 11, 6), args=['text']) sched.start()

You can specify the exact time when the job should be run:

# The job will be executed on November 6th, 2009 at 16:30:05
sched.add_job(my_job, 'date', run_date=datetime(2009, 11, 6, 16, 30, 5), args=['text'])

The run date can be given as text too:

sched.add_job(my_job, 'date', run_date='2009-11-06 16:30:05', args=['text'])

To add a job to be run immediately:

# The 'date' trigger and datetime.now() as run_date are implicit
sched.add_job(my_job, args=['text'])

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

  1. APScheduler API -- apscheduler.triggers.interval

    apscheduler.triggers.interval API Trigger alias for add_job(): interval class apscheduler.triggers.i ...

  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. Java 基础 常用API ( 正则表达式,Date类,DateFormat类,Calendar类 )

    正则表达式 正则表达式的概念 正则表达式(英语:Regular Expression,在代码中常简写为regex). 正则表达式是一个字符串,使用单个字符串来描述.用来定义匹配规则,匹配一系列符合某个 ...

  5. Java8 Time API与老Date之间的转换

    前面我已经总结了Java8 Time API常用的一些方法.封装的工具类,可是最近需要对一个比较老的项目进行重构,大致看了一下使用的Jdk还是7而且里面的时间工具类还是使用的Date和Calendar ...

  6. 常用API——日期型函数Date

    上图 ·声明 var myDate = new Date(); //系统当前时间 var myDate = new Date(yyyy, mm, dd, hh, mm, ss); var myDate ...

  7. [Day16]常用API(正则表达式、Date类、DateFormat类、Calendar类)

    1.正则表达式(Regular Expression,regex)-是一个字符串,使用单个字符串来描述.用来定义匹配规则,匹配一系列符合某个句法规则的字符串 1.1匹配规则: (1)字符:x -代表的 ...

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

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

  9. python APScheduler模块

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

随机推荐

  1. JDBC的基础接口及其用法

    JDBC基础 所谓JDBC即是:Java DataBase Connectivity,java与数据库的连接.是一些用来执行SQL语句的Java API. 我们进行JDBC的编程,主要常用的几个概念: ...

  2. 如何规范 CSS 的命名和书写

    我开始学前端的时候也是对于规范问题头疼,后来看了网易的NEC规范,惊呼牛逼 NEC : 更好的CSS样式解决方案 只遵循横向顺序即可,先显示定位布局类属性,后盒模型等自身属性,最后是文本类及修饰类属性 ...

  3. sqlserver查询数据库中包含某个字段的所有表和所有存储过程

    1.查询包含某字段的所有表 select object_name(id) objName,Name as colName from syscolumns where (name like'%你要查询的 ...

  4. 对HashMap的理解(三):ConcurrentHashMap

    HashMap不是线程安全的.在并发插入元素的时候,有可能出现环链表,让下一次读操作出现死循环.避免HashMap的线程安全问题有很多方法,比如改用HashTable或Collections.sync ...

  5. Visual Categorization with Bags of Keypoints

    1.Introduction and backgrounds 作为本周的论文之一,这是一篇bag of features的基本文章之一,主要了解其中的基本思路,以及用到的基本技术,尽量使得细节更加清楚 ...

  6. P3293 [SCOI2016]美味

    题目描述 一家餐厅有 n 道菜,编号 1...n ,大家对第 i 道菜的评价值为 ai(1<=i<=n).有 m 位顾客,第 i 位顾客的期望值为 bi,而他的偏好值为 xi .因此,第 ...

  7. VS2013 UML 如何复制文件

    如:复制活动图,文件复制了显示不了 正确做法:新建活动图,打开源活动图,全选,复制,在新建的活动图粘贴,以此实现复制

  8. linux内核分析 第六周 分析Linux内核创建一个新进程的过程

    进程的描述 操作系统的三大管理功能:进程管理.内存管理.文件系统 为了管理进程,内核必须对每个进程进行清晰的描述,进程描述符提供了内核所需了解的进程信息. 进程控制块PCB task_struct:进 ...

  9. oracle的loop

    oracle的loop等循环语句的几个用法小例子 --loop循环用法 (输出1到10) ) :; begin loop v_num :; ; --上面退出循环也可以用下面3行 /* if(v_num ...

  10. 目标检测应用化之web页面(YOLO、SSD等)

    在caffe源码目录下的examples下面有个web_demo演示代码,其使用python搭建了Flask web服务器进行ImageNet图像分类的演示. 首先安装python的依赖库:pip i ...