gpt4 book ai didi

ruby-on-rails - 在每当 gem 中,如果我们使用每个 :month, 是否意味着月末或开始?

转载 作者:行者123 更新时间:2023-12-04 16:31:31 25 4
gpt4 key购买 nike

使用 whenever 时gem 我们可以像这样设置每月工作:

every :month do
...
end

这会在月底还是月初运行作业?我想在最后运行它。

最佳答案

来自 the tests in whenever repo :

assert_equal '0 0 1 * *',  parse_time(:month)

所以 :month将生成一个看起来像 0 0 1 * *.. 的 cron 条目

这对应于 run once a month at midnight of the first day of the month .

使作业在每月最后一天运行的一种方法是在任何地方使用原始 cron 条目,如下所示:
every '0 0 L * *' do
...
end

这假设服务器上的 cron 支持 L代表月份最后一天的标志。

Cron job to run on the last day of the month有关在本月最后一天运行 cron 作业的更多信息。

关于ruby-on-rails - 在每当 gem 中,如果我们使用每个 :month, 是否意味着月末或开始?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30287818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com