javan/whenever

ArgumentError: Couldn't parse: "1/1 * * *"

vp993 opened this issue · 4 comments

vp993 commented

Hi @javan,

Thanks for you gem, I've been using it for at least 7 years already.

Here is the issue, I want to set up a job to run at the time defined by this https://cron.help/#1/1__**, but your gem doesn't support it.
Could you fix your REGEX here https://github.com/javan/whenever/blob/master/lib/whenever/cron.rb#L9 to cover this case? There are a lot of tested REGEXs on the internet.

Here is my schedule.rb

every '1/1 * * *' do
  rake 'payouts:check_withdrawals'
end

Here is the stack trace:

ArgumentError: Couldn't parse: "1/1 * * *"
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/cron.rb:150:in `parse_as_string'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/cron.rb:54:in `time_in_cron_syntax'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/cron.rb:46:in `output'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/cron.rb:40:in `block (2 levels) in output'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/cron.rb:39:in `each'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/cron.rb:39:in `block in output'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/cron.rb:38:in `each'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/cron.rb:38:in `output'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/job_list.rb:145:in `block in cron_jobs_of_time'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/job_list.rb:141:in `each'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/job_list.rb:141:in `cron_jobs_of_time'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/job_list.rb:166:in `block in cron_jobs'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/job_list.rb:165:in `each'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/job_list.rb:165:in `cron_jobs'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/job_list.rb:75:in `generate_cron_output'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever.rb:12:in `cron'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/command_line.rb:57:in `whenever_cron'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/command_line.rb:111:in `updated_crontab'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/command_line.rb:38:in `run'
  /usr/local/bundle/gems/whenever-1.0.0/lib/whenever/command_line.rb:6:in `execute'
  /usr/local/bundle/gems/whenever-1.0.0/bin/whenever:44:in `<top (required)>'
  /usr/local/bundle/bin/whenever:23:in `load'
  /usr/local/bundle/bin/whenever:23:in `<top (required)>'

Could you maybe take a shot at a PR to fix this? Remember to include tests and a changelog entry for approval.

vp993 commented

@benlangfeld I wish, but I don't have enough time for that. This issue is a good option for newcomers to make a contribution to the prominent project. I'll share it in Ruby dev groups.

If you need it but don’t have enough time for it, I don’t think it’s reasonable to ask it of the maintainers of such a project. Maybe you have an intern or junior developer on your team who you can have do it, or you could always hire a contractor.

vp993 commented

Agreed, that's why I decided to share it in Ruby dev groups. Anyway, the issue was on my side:

every '1/1 * * *' do
  rake 'payouts:check_withdrawals'
end

It had missed * because cron requires 5 params. Thanks, the issue is closed.