使用 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/