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. Installing Percona XtraDB Cluster on CentOS

    PXC简介 Percona XtraDB Cluster(简称PXC集群)提供了MySQL高可用的一种实现方法. 1.集群是有节点组成的,推荐配置至少3个节点,但是也可以运行在2个节点上. 2.每个节 ...

  2. Python批量文件重命名

    今天,得到一个里面都是图片的文件夹,但是图片都没有后缀,因此想用Pythton批量地为所有的文件加上".jpg"的后缀,代码如下: #-*- coding:utf-8 -*- #重 ...

  3. 自定义smokeping告警(邮件+短信)

    前段时间接到公司IT同事需求,帮助其配置smokeping的告警功能,之前配置的姿势有些问题,告警有些问题,现在调试OK,在此将关键配置点简单记录下. 关键的配置项主要有: 定义告警规则并配置将告警信 ...

  4. 【比赛】NOIP2017 小凯的疑惑

    找规律:ans=a*b-a-b 证明:(可见 体系知识) gcd(A, B) = 1 → lcm(A, B) = AB 剩余类,把所有整数划分成m个等价类,每个等价类由相互同余的整数组成 任何数分成m ...

  5. Java8 新特性Stream 的学习和使用方法

    流(Stream) 流是java 8 中新引入的特性,用来处理集合中的数据,Stream 是一个来自数据源的元素队列并支持聚合操作. Java 中 Stream 不会存储元素. 数据源 流的来源. 可 ...

  6. 51nod乘积之和

    题目链接 戳我 题意简述 你有长为\(n\)的序列和\(Q\)个询问,每次询问一个\(k\),求用\(k\)个数组成的不同方案的乘积的和. sol 显然要预处理一波. 考虑分治,左右两边都求出来后,怎 ...

  7. APT攻击基础科普

    0x00 APT的历史起源背景 APT这个词汇最早起源于:2005年英国和美国的CERT组织发布了关于有针对性的社交工程电子邮件,放弃特洛伊木马以泄露敏感信息的第一个警告,尽管没有使用“APT”这个名 ...

  8. 6: Junit1_@Test

    @Test注解是测试的基础,它提供了其他作用 1.指定将会抛出的异常类型,如果没有抛出异常或者抛出的一场不属于我们指定的类型,就会算是测试失败了. @Test(expected = RuntimeEx ...

  9. ECharts.js 简单示例

    ECharts.js学习(一) 简单入门 EChart.js 简单入门 最近有一个统计的项目要做,在前端的数据需要用图表的形式展示.网上搜索了一下,发现有几种统计图库. MSChart   这个是Vi ...

  10. js正则取出一个字符串小括号中的内容

    var aa="ldfjsldfj(dsfasjfj3124123)"; var result = aa.match(/\(([^)]*)\)/); // 此时result=[&q ...