Rails 每当 gem:每月 20 日
我在互联网上搜索了这一点,并且文档并没有真正具体讨论每月的工作。所以我希望这里有人能告诉我如何做到这一点。
我已经安装了whenever gem,我需要知道的是正确的语法:
every :month, :on => '20th', :at => '02:00' do
runner "Mailer.send_friend_sheet"
end
希望有人能指出我正确的方向..
谢谢!
I searched all over the internet for this, and the documentation isn't really talking about monthly jobs in specific. So I was hoping that someone here could tell me how to do this.
I've installed the whenever gem and all I need to know is the right syntax for this:
every :month, :on => '20th', :at => '02:00' do
runner "Mailer.send_friend_sheet"
end
Hope someone can point me in the right direction..
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您不知道如何使用 ruby 语法,您也可以使用原始 cron 语法。
你想要的看起来像:
这是一个关于如何使用 cron 语法的快速备忘单
,无耻地窃取自:http:// /adminschoice.com/crontab-quick-reference
You can use raw cron syntax as well if you cant figure out how to use with ruby syntax.
What you want will look like:
Here is a quick cheatsheet for how to use cron syntax
Shamelessly stolen from: http://adminschoice.com/crontab-quick-reference
如果您希望它更具可读性,您也可以只解析文本中的日期。
这也会生成
0 2 20 * *
。If you want it more readable you can also just parse a date in text.
This will generate
0 2 20 * *
as well.更好的是:
Even better:
据我所知,每当不支持
:on
选项,但您应该能够执行“0 2 20 * *”只是相关的 cron 语法 - 请参阅 http://www.manpagez.com/man/5/crontab/
Whenever doesn't support an
:on
option as far as I am aware, but you should be able to doThe '0 2 20 * *' is simply the relevant cron syntax - see http://www.manpagez.com/man/5/crontab/