我在互联网上到处寻找,文档中并没有具体谈到月度工作。所以我希望这里有人能告诉我怎么做。
我已经安装了什么时候的gem,我需要知道的就是正确的语法:
every :month, :on => '20th', :at => '02:00' do
runner "Mailer.send_friend_sheet"
end希望有人能给我指明正确的方向。
谢谢!
发布于 2011-06-23 20:34:02
据我所知,无论何时都不支持:on选项,但您应该能够这样做
every '0 2 20 * *' do
runner "Mailer.send_friend_sheet"
end'0 2 20 * *‘只是相关的cron语法-请参阅http://www.manpagez.com/man/5/crontab/
发布于 2011-06-23 20:34:15
如果你不知道如何使用ruby语法,你也可以使用raw cron语法。
您需要的内容将如下所示:
every '0 2 20 * *' do
command "echo 'you can use raw cron syntax too'"
end下面是如何使用cron语法的快速指南
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)不知羞耻地窃取自:http://adminschoice.com/crontab-quick-reference
发布于 2013-05-20 18:14:41
如果你想让它更具可读性,你也可以只解析文本形式的日期。
every 1.month, :at => 'January 20th 2:00am' do
runner "Mailer.send_friend_sheet"
end这也将生成0 2 20 * *。
https://stackoverflow.com/questions/6453618
复制相似问题