Crono runs the task just the first time #32

Closed
opened 2025-12-29 00:21:36 +01:00 by adam · 3 comments
Owner

Originally created by @vandamon on GitHub (Mar 31, 2016).

This is an awesome gem, if only it can do what it says.

Crono runs my tasks, but just once, for the first time.

My cronotab looks like this:

require 'rake'
Quadra::Application.load_tasks

class InvoiceUpsert
  def perform
    Rake::Task['invoice:batch_upsert'].invoke
  end
end

class PaymentUpsert
  def perform
    Rake::Task['payment:batch_upsert'].invoke
  end
end


Crono.perform(PaymentUpsert).every 1.day, at: { hour: 02, min: 15 }
Crono.perform(InvoiceUpsert).every 15.minutes

Any suggestions? Or is this a bug?

Originally created by @vandamon on GitHub (Mar 31, 2016). This is an awesome gem, if only it can do what it says. Crono runs my tasks, but just once, for the first time. My cronotab looks like this: ``` require 'rake' Quadra::Application.load_tasks class InvoiceUpsert def perform Rake::Task['invoice:batch_upsert'].invoke end end class PaymentUpsert def perform Rake::Task['payment:batch_upsert'].invoke end end Crono.perform(PaymentUpsert).every 1.day, at: { hour: 02, min: 15 } Crono.perform(InvoiceUpsert).every 15.minutes ``` Any suggestions? Or is this a bug?
adam closed this issue 2025-12-29 00:21:36 +01:00
Author
Owner

@Blacksmoke16 commented on GitHub (Apr 20, 2016):

+1

@Blacksmoke16 commented on GitHub (Apr 20, 2016): +1
Author
Owner

@klausmeyer commented on GitHub (May 10, 2016):

Try using Rake::Task#execute instead of Rake::Task#invoke.

Background: Invoke only runs the task "if needed".
Since crono doesn't boot a fresh instance of your application per job execution (like regular cronjobs would do) the task is considered als already executed after the first run if you use invoke.

@klausmeyer commented on GitHub (May 10, 2016): Try using `Rake::Task#execute` instead of `Rake::Task#invoke`. Background: Invoke only runs the task "if needed". Since crono doesn't boot a fresh instance of your application per job execution (like regular cronjobs would do) the task is considered als already executed after the first run if you use `invoke`.
Author
Owner

@vandamon commented on GitHub (Jun 22, 2016):

@klausmeyer Thanks a lot for the suggestion. I have it working now.

@vandamon commented on GitHub (Jun 22, 2016): @klausmeyer Thanks a lot for the suggestion. I have it working now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/crono#32