[Backgroundrb-devel] Schedule parser

Meng Kuan mengkuan at gmail.com
Thu Jan 31 01:34:51 EST 2008


On 31 Jan 2008, at 2:19 AM, Meng Kuan wrote:

>
> On 31 Jan 2008, at 2:12 AM, Scott Ward wrote:
>
>> I wonder if its because you need 7 entries for trigger_args?
>>
>>> From the docs:
>>
>> The fields (which can be an asterisk, meaning all valid patterns)  
>> are:
>>     sec[0,59] min[0,59], hour[0,23], day[1,31], month[1,12],  
>> weekday[0,6],
>> year
>>
>> Looks like you're missing "year".  Of course, that may not be  
>> right since
>> your second example works...
>>
>
> I just added a '*' to the end for the 'year' argument as you  
> mentioned but same results. The year argument is probably optional.
>
>
> Btw, the trigger_args that actually worked for me is
>
>   :trigger_args: 30 * 0,1,2 * * 2,3,4,5,6
>
>
> This one that I posted in my first mail gave the same errors:
>
>   :trigger_args: 30 * 0,1 * * 2,3,4,5,6


The above still did not solve the problem. So I dug deeper and found  
a possible logic bug in cron_trigger.rb file. It appears that  
cron_trigger incremented the day value beyond the number of days of  
the current month (from 31 to 32) and this caused the Time.local call  
to abort.

Here's my patch to adjust for this.

$ diff -c3 cron_trigger.rb cron_trigger.rb.new
*** cron_trigger.rb     Thu Dec 20 17:27:47 2007
--- cron_trigger.rb.new Thu Jan 31 14:25:57 2008
***************
*** 126,131 ****
--- 126,135 ----
             if next_hour < hour
               hour = next_hour
               day += 1
+             if day > month_days(year, month)
+               day -= month_days(year, month)
+               month += 1
+             end
               retry
             end
             hour = next_hour


This seems to finally fix the problem for me.

cheers,
mengkuan


More information about the Backgroundrb-devel mailing list