resque 调度程序上的 cron 不按首选时间间隔工作
cron on resque scheduler not working on preferred intervals
我需要在每个星期四上午 10 点准时运行 执行一项任务,
在 resque yaml 文件上我正在尝试这个
cron: "* 10 * * 4 * America/New_York" # expecting this to shoot out every thursday..
对吗?我无法测试它,因为我等不及这样的间隔,所以我尝试至少每 5 分钟测试一次,但它不是很有希望
cron: "5 * * * * *" # It runs for every single minute..
如有任何帮助或指导,我们将不胜感激。
我关注了这个
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
正则表达式可以有 5 或 6 个占位符。并非每个 framework/implementation 都支持这两种方式,因此您必须检查您需要哪种格式。
您的表达式 cron: "5 * * * * *"
每分钟会 运行 整整 5 秒。
我认为在你的情况下,你只能使用 5 个占位符,这意味着你不能安排几秒钟,而只能安排几分钟。
此外,要每 5 分钟 运行 某件事,您需要以下表达式:
cron: "*/5 * * * *"
星期四每个上午 10 点应该是:
cron: "0 10 * * 4 America/New_York"
含义:
- 每个星期四 (4)
- 每个月
- 每天
- 10 小时
- 0 分钟
(我没有测试过这个。)
cron 通常只有 5 个字段。您使用的 cron 实现允许 6 个字段,但第一个字段代表秒而不是分钟。来自 https://github.com/resque/resque-scheduler:
NOTE: Six parameter cron's are also supported (as they supported by rufus-scheduler which powers the resque-scheduler process). This allows you to schedule jobs per second (ie: "30 * * * * *" would fire a job every 30 seconds past the minute).
所以你应该回到正常的 5 个字段并使用 @thomas-d 的答案。
传统5字段格式为:
Minute Hour Day_of_the_Month Month_of_the_Year Day_of_the_Week
我需要在每个星期四上午 10 点准时运行 执行一项任务,
在 resque yaml 文件上我正在尝试这个
cron: "* 10 * * 4 * America/New_York" # expecting this to shoot out every thursday..
对吗?我无法测试它,因为我等不及这样的间隔,所以我尝试至少每 5 分钟测试一次,但它不是很有希望
cron: "5 * * * * *" # It runs for every single minute..
如有任何帮助或指导,我们将不胜感激。
我关注了这个
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
正则表达式可以有 5 或 6 个占位符。并非每个 framework/implementation 都支持这两种方式,因此您必须检查您需要哪种格式。
您的表达式 cron: "5 * * * * *"
每分钟会 运行 整整 5 秒。
我认为在你的情况下,你只能使用 5 个占位符,这意味着你不能安排几秒钟,而只能安排几分钟。
此外,要每 5 分钟 运行 某件事,您需要以下表达式:
cron: "*/5 * * * *"
星期四每个上午 10 点应该是:
cron: "0 10 * * 4 America/New_York"
含义:
- 每个星期四 (4)
- 每个月
- 每天
- 10 小时
- 0 分钟
(我没有测试过这个。)
cron 通常只有 5 个字段。您使用的 cron 实现允许 6 个字段,但第一个字段代表秒而不是分钟。来自 https://github.com/resque/resque-scheduler:
NOTE: Six parameter cron's are also supported (as they supported by rufus-scheduler which powers the resque-scheduler process). This allows you to schedule jobs per second (ie: "30 * * * * *" would fire a job every 30 seconds past the minute).
所以你应该回到正常的 5 个字段并使用 @thomas-d 的答案。
传统5字段格式为:
Minute Hour Day_of_the_Month Month_of_the_Year Day_of_the_Week