On Dec 30, 2009, at 2:12 AM, David Angga wrote: > try : 55 11 01 * *
55 23 1 * * ... so you get 5 min. before midnight (not 5 min. before noon) > > regards > > On Wed, Dec 30, 2009 at 12:55 PM, Newb Newb <[email protected]> > wrote: > Newb Newb wrote: > > Dear All, > > i m running cron task in my application using whenever gem. > > the below code runs the rake every month. > > every 1.month, :at => '11:55pm' do > > but i want to run this rake on 1st date of every month. > > how can i do it. > > pls guide me on this. > > Some one pls help me > -- > -- > David Angga Prasetya > Ruby on Rails developer > @ http://kiranatama.com - a Ruby on Rails outsourcing company > But to get the help that you seem to be asking for, you'll have to give a bit more information. Ah! I overlooked the 'whenever' gem. Since I found that I have that gem installed (although I can't recall when or why), the docs are really sparse and the code doesn't seem to know how to cope with a time or frequency option that will do what you want. In particular, lib/outputs/cron.rb says that the :at option can't be used in this case: every :month do command "something" end gives: @monthly something but trying to get what you want with: every :month, :at => '11:55pm' do command "something" end or even: every :month do command "something", :at => '11:55pm' end appears to just give (from line 41): ArgumentError: comparison of Time with 0 failed although I would have expected (from line 42): You cannot specify an ':at' when using the shortcuts for times. I can get this error if I try something like: every :month, :at => 1 do command "something" end or even: every :month do command "something", :at => 1 end There seems to be a bug in lib/outputs/cron.rb:41 where @at > 0 appears. The @at might be a 0, but is more likely a Time returned from Chronic.parse on line 11. Now, the particulars of using: every :month do ... end to get a crontab line with: @monthly ... might not be exactly what you want since (at least on Mac OS X) the man page says: string meaning ------ ------- @monthly Run once a month, "0 0 1 * *". Of course, that doesn't really get you much closer to forcing: "55 23 1 * * ..." I think that you might have to change the behavior in lib/outputs/ cron.rb to shift from the "@monthly " to the "0 0 1 * * " syntax when given :at, but also probably adjust the way that the job is created and stuffed into the @jobs hash. In the course of thinking about where and how to make the change which would permit one of the nice syntaxes above, I realized that you could say: every 1.month, :at => Time.parse('01 23:55') do command 'something' end since the parse_time function only looks at the #min, #hour, and #day methods of the given Time: 55 23 1 * * something It's a feature of Time.parse to fill-in with parts of the current date/ time when bits are missing: Time.parse('01 23:55') => Tue Dec 01 23:55:00 -0500 2009 -Rob Rob Biedenharn http://agileconsultingllc.com [email protected] http://gaslightsoftware.com/ [email protected] -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

