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

标签 ruby-on-rails whenever

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

相关文章:

ruby-on-rails - jQuery ajax 请求未触发 Rails Controller 的 JS 响应?

ruby-on-rails - 如果父记录有子记录,如何防止删除?

ruby-on-rails - Sidekiq Rails 4.2 使用 Active Job 还是 Worker?有什么不同

ruby-on-rails - 如何在 Rails 中使用 whenever gem 运行 Controller 操作?

ruby-on-rails-3 - 如何使用 'Whenever' gem ?

ruby-on-rails - 每当 rails 3 ubuntu 的 crontab 文件中的 PATH

ruby-on-rails - 如何更改 Rails 3 路由中的默认参数名称?

ruby-on-rails - 在 activeadmin 资源中需要范围

ruby-on-rails - 将模块与 attr_accessible、has_one、has_many 混合

ruby-on-rails - 在cron中运行的rake任务找不到数据库表