angularjs - 为这些用例定义 Node 议程作业

标签 angularjs node.js date jobs job-scheduling

您好,我正在使用 Node 议程在我的应用程序 (https://github.com/rschmukler/agenda) 中定义作业。我有两个我不知道如何涵盖的用例

1) 例如,我希望作业每周二或每周三运行

2) 我希望作业每 5 日或 10 日运行一次。

我知道 Node 议程使用人工间隔 ( https://github.com/rschmukler/human-interval ) 来解释他们想要运行作业的频率,但我看到它只能解释天、周、月等单位。关于我如何做的任何想法可以涵盖我上面提到的两个用例吗?

对于用例 1,我发现我可以这样做(来自议程文档):

var weeklyReport = agenda.schedule('Saturday at noon', 'send email report', {to: 'another-guy@example.com'});
weeklyReport.repeatEvery('1 week').save();
agenda.start();

最佳答案

您可以使用 cron 格式:

1) weeklyReport.repeatEvery( "0 0 * * 1,4")

其中 1 是星期一,4 是星期四

2) weeklyReport.repeatEvery("0 0 1,15 * *")

这将在每月的 1 号和 15 号运行

关于angularjs - 为这些用例定义 Node 议程作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30996605/

相关文章:

angularjs - 如何取消 RestAngular promise .then()?

node.js - 如何使用通过 Npm 安装的 Semantic UI?

Node.js 和密码安全 : three questions

javascript - new Date() 在 Chrome 和 Firefox 中的工作方式不同

php 程序找到我的生日,其中日期名称 "Monday"再过 100 年

javascript - API 完成后初始化指令

javascript - 使用 ng-angular 动态创建的元素不会触发 onClick 事件

javascript - Angular 数据表 : How to retrieve selected row data for Editing/Delete

node.js - 如何在异步函数中使用 "this"?

php - 如何使用数组中的 date_diff() 查找两个日期之间的差异