首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更新crontab (只要是gem)

更新crontab (只要是gem)
EN

Stack Overflow用户
提问于 2019-01-04 00:00:02
回答 1查看 150关注 0票数 2

通过执行whenever -update-crontab命令,将返回以下错误:

代码语言:javascript
复制
/usr/lib/ruby/vendor_ruby/whenever/cron.rb:132:in `parse_as_string': Couldn't parse: 31557600 (ArgumentError)
    from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:112:in `parse_time'
    from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:50:in `time_in_cron_syntax'
    from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:42:in `output'
    from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:36:in `block (2 levels) in output'
    from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:35:in `each'
    from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:35:in `block in output'
    from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:34:in `each'
    from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:34:in `output'
    from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:151:in `block (2 levels) in cron_jobs'
    from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:147:in `each'
    from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:147:in `block in cron_jobs'
    from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:146:in `each'
    from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:146:in `cron_jobs'
    from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:65:in `generate_cron_output'
    from /usr/lib/ruby/vendor_ruby/whenever.rb:10:in `cron'
    from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:54:in `whenever_cron'
    from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:106:in `updated_crontab'
    from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:35:in `run'
    from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:6:in `execute'
    from /usr/bin/whenever:41:in `<main>'

我的schedule.rb文件:

代码语言:javascript
复制
every 1.year do
  rake "maintenances:renew"
end

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-04 22:00:11

如果您在使用1.year方法时遇到问题,您可以使用以下两种替代方法。

1-快捷键

代码语言:javascript
复制
every :year do
  rake "maintenances:renew"
end

2-表达式

代码语言:javascript
复制
every '0 0 1 12 *' do
  rake "maintenances:renew"
end

如果您想了解有关这些选项的更多信息,请查看official documentation

要测试表达式,我推荐使用crontab.guru

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54025785

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档