使用cron表达式的轻量级任务调度程序。

crython的Python项目详细描述


Join the chat at https://gitter.im/crython/Lobby

Build StatusBuild statuscodecovCode ClimateIssue Count

PyPI versionPyPI versions

Stories in Ready

crython是一个轻量级的任务(函数)调度程序,使用 cron表达式写入 Python。

状态

此模块是主动维护的。

安装

pip安装crython:

$ pip install crython

要从源安装Crython,请执行以下操作:

$ git clone git@github.com:ahawker/crython.git
$ python setup.py install

用法

Crython支持七个字段(秒、分、小时、月日, 月、工作日、年)。

每分钟调用一次函数:

importcrython# Fire once a minute.@crython.job(second=0)deffoo():print"... while heavy sack beatings are up a shocking nine hundred percent? - Kent Brockman"

每隔10秒调用一个函数:

# Fire every 10 seconds.@crython.job(second=range(0,60,10))deffoo():print"I'm a big four-eyed lame-o and I wear the same stupid sweater every day. - Homer's Brain"

使用单个cron表达式调用函数:

# Fire every 10 seconds.@crython.job(second='*/10')deffoo():print"Hail to the thee Kamp Krusty... - Kampers"

使用完整的cron表达式调用函数:

# Fire once a week.@crython.job(expr='0 0 0 * * 0 *')deffoo():print"Back in line, maggot! - Kearny"

使用位置和/或关键字参数调用函数:

# Fire every second.@job('safety gloves',second='*',name='Homer Simpson')deffoo(item,name):print"Well, I don't need {0}, because I'm {1}. -- Grimey".format(item,name)

使用predefined keywords

调用函数
# Fire once a day.@crython.job(expr='@daily')deffoo():print"That's where I saw the leprechaun. He tells me to burn things! - Ralph Wiggum"
# Fire once immediately after scheduler starts.@crython.job(expr='@reboot')deffoo():print"I call the big one bitey. - Homer Simpson"

调用函数并在单独的线程中运行它(默认行为 如果未指定ctx

# Fire once a week.@crython.job(expr='@weekly',ctx='thread')deffoo():print"No, no, dig up stupid. - Chief Wiggum"

调用函数并在单独的进程中运行它:

# Fire every hour.@crython.job(expr='@hourly',ctx='multiprocess')deffoo():print"Eat my shorts. - Bart Simpson"

启动全局作业计划程序:

if__name__=='__main__':crython.start()

关键词

EntryDescriptionEquivalent To
@yearly/@annuallyRun once a year at midnight in the morning of January 10 0 0 0 1 1 *
@monthlyRun once a month at midnight in the morning of the first of the month0 0 0 0 1 * *
@weeklyRun once a week at midnight in the morning of Sunday0 0 0 0 * 0 *
@dailyRun once a day at midnight0 0 0 * * * *
@hourlyRun once an hour at the beginning of the hour0 0 * * * * *
@minutelyRun once a minute at the beginning of the minute0 * * * * * *
@rebootRun once at startup@reboot

待办事项

  • 支持“L”、“W”和“”特价。
  • 确定从现在开始的时间增量->;下一个时间表达式有效。

贡献

如果您想贡献,只需分叉存储库,推动 更改并发送请求。

许可证

Crython在MIT license下提供。

参见其他

有类似的python cron库。见: pycronpython-crontabcronex

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
地址簿在地址簿中添加和检查Java中的条目   java在请求范围中存储和检索值   java Android:您能否使用AlertDialog清除数据,以便在启动电子邮件活动后数据不会损坏?   用户和角色的javajpa设计   java为什么mybatis更新和删除不起作用?   在使用swingx jxtreetable进行测试时,java Fest的速度会减慢   如何使用ApachePOI4.0XDDFChartData、XDDFBarChartData生成堆叠条形图;在使用java的excel工作表中,我不想使用jfree   oauth Java执行oAuth1。0具有给定consumerKey、ConsumerCret、accessToken、accessTokenSecret和realm的已验证请求   java TTS OuttanceProgressListener无法正常工作   java if条件在不同的环境中返回不同的值   java Spring Boot应用程序的嵌入式HTTP服务器在哪里?   基于SSL的java SOAP客户端:sun。安全供应商。certpath。SunCertPathBuilderException:找不到请求目标的有效证书路径   java StringBuilder()与StringBuilder(空)与StringBuilder(“”)