【问题标题】:Perl module for scheduled jobs - bit like cron用于计划作业的 Perl 模块 - 有点像 cron
【发布时间】:2010-07-16 07:28:49
【问题描述】:

我开始编写一个用于调度 perl 作业的模块,它的语法比 cron 作业更具可读性,但想知道是否已经有一个可用的模块。

我正在寻找可以从 perl 脚本而不是 crontab 文件运行的东西。这种语法必须易于阅读。例如:-

every Monday morning
every other Tuesday at 3:30pm
every night
once only on 14th August 2010 at 2pm

..如果有一些与此类似的东西,那就太好了。我快速浏览了 CPAN,但找不到我想要的。

【问题讨论】:

    标签: perl cron


    【解决方案1】:

    看起来 CPAN 的 DateTime::Format::Natural 是这样做的。不幸的是,文档几乎不存在。从我找到的模块自检文件中剔除:

    { '9 in the evening'                => '24.11.2006 21:00:00' },
    { 'monday 6 in the morning'         => '20.11.2006 06:00:00' },
    { 'monday 4 in the afternoon'       => '20.11.2006 16:00:00' },
    { 'monday 9 in the evening'         => '20.11.2006 21:00:00' },
    { 'last sunday at 21:45'            => '19.11.2006 21:45:00' },
    { 'monday last week'                => '13.11.2006 00:00:00' },
    { '6th day last week'               => '18.11.2006 00:00:00' },
    { '6th day this week'               => '25.11.2006 00:00:00' },
    { '6th day next week'               => '02.12.2006 00:00:00' },
    { '12th day last month'             => '12.10.2006 00:00:00' },
    { '12th day this month'             => '12.11.2006 00:00:00' },
    { '12th day next month'             => '12.12.2006 00:00:00' },
    { '1st day last year'               => '01.01.2005 00:00:00' },
    { '1st day this year'               => '01.01.2006 00:00:00' },
    { '1st day next year'               => '01.01.2007 00:00:00' },
    

    看起来很有希望。

    【讨论】:

    【解决方案2】:

    Schedule::Cron 可以满足您的需求。

    【讨论】:

    • 它没有自然的日期格式,只有正常的 crontab 日期。
    • @dalton:是的,您必须使用其他模块(如 DateTime::Format 系列中的某些东西,如 msw 所示)。
    猜你喜欢
    • 1970-01-01
    • 2010-09-12
    • 2019-01-23
    • 1970-01-01
    • 2019-06-24
    • 2014-05-26
    • 1970-01-01
    • 2018-10-03
    相关资源
    最近更新 更多