schedule README

The project's README from github.com/dbader/schedule. As one markdown file: README.md.

schedule <https://schedule.readthedocs.io/>__

.. image:: https://github.com/dbader/schedule/workflows/Tests/badge.svg :target: https://github.com/dbader/schedule/actions?query=workflow%3ATests+branch%3Amaster

.. image:: https://coveralls.io/repos/dbader/schedule/badge.svg?branch=master :target: https://coveralls.io/r/dbader/schedule

.. image:: https://img.shields.io/pypi/v/schedule.svg :target: https://pypi.python.org/pypi/schedule

Python job scheduling for humans. Run Python functions (or any other callable) periodically using a friendly syntax.

Usage

.. code-block:: bash

$ pip install schedule

.. code-block:: python

import schedule
import time

def job():
    print("I'm working...")

schedule.every(10).seconds.do(job)
schedule.every(10).minutes.do(job)
schedule.every().hour.do(job)
schedule.every().day.at("10:30").do(job)
schedule.every(5).to(10).minutes.do(job)
schedule.every().monday.do(job)
schedule.every().wednesday.at("13:15").do(job)
schedule.every().day.at("12:42", "Europe/Amsterdam").do(job)
schedule.every().minute.at(":17").do(job)

def job_with_argument(name):
    print(f"I am {name}")

schedule.every(10).seconds.do(job_with_argument, name="Peter")

while True:
    schedule.run_pending()
    time.sleep(1)

Documentation

Schedule's documentation lives at schedule.readthedocs.io <https://schedule.readthedocs.io/>_.

Meta

Daniel Bader - @dbader_org <https://twitter.com/dbader_org>_ - [email protected]

Inspired by Adam Wiggins' <https://github.com/adamwiggins>_ article "Rethinking Cron" <https://adam.herokuapp.com/past/2010/4/13/rethinking_cron/>_ and the clockwork <https://github.com/Rykian/clockwork>_ Ruby module.

Distributed under the MIT license. See LICENSE.txt <https://github.com/dbader/schedule/blob/master/LICENSE.txt>_ for more information.

https://github.com/dbader/schedule

schedule (dbader/schedule)

Searching Database…

12.3K ·GitHub
这是什么?Schedule 是一个轻量级的 Python 库,用简单易读的语法定时执行任务,例如每 10 秒运行一次某个函数,或每周一运行一次。
它是库还是独立的调度程序应用?它是一个进程内库,你把它导入到自己的 Python 脚本中;它在你应用的循环里运行,而不是作为单独的守护进程或 cron 服务。
怎样把它加到我的项目里?用 pip 安装,导入 schedule,用 schedule.every() 定义任务,然后在循环中调用 schedule.run_pending()。
除了安装 Python,还需要别的东西吗?不需要,它没有外部依赖,是一个单独的轻量级包。
它会在后台自动运行任务吗?不会,你必须让自己的循环一直运行,并反复调用 schedule.run_pending()(例如配合 time.sleep(1));默认情况下没有后台线程。
它支持哪些平台?它是纯 Python 实现,没有原生依赖,因此只要有可用的受支持 Python 解释器,就能在 Linux、macOS 和 Windows 上运行。
可以定义哪些类型的调度?你可以按秒、分钟、小时、天、特定星期(如周一或周三)、特定时间、带时区的时间,甚至随机间隔(如每 5 到 10 分钟)来安排任务。
可以给定时任务传递参数吗?可以,你可以直接在 .do() 调用中传递参数,例如 schedule.every(10).seconds.do(jobwithargument, name='Peter')。
在哪里可以找到完整文档?完整文档托管在 schedule.readthedocs.io。
Creator
dbader
Size
0.4 MB
Stars
12.3K
Updated
CommitMay 25
Age
13y
Commits · 90 Days