plashchynski / crono

A time-based background job scheduler daemon (just like Cron) for Rails
https://github.com/plashchynski/crono
Apache License 2.0
687 stars 56 forks source link

Daily Job Not Perform as Expected #70

Open shenhf opened 7 years ago

shenhf commented 7 years ago

I created a crono job to send birthday email every day at 7:30 PM. It was supposed to run only once in one day! Crono.perform(BirthdayJob).every 1.day, at: '07:30'

Crono started at 7:30 as expected, but after that it "LOST CONTROLL", it was performed periodically, here is the log: I, [2017-11-11T07:30:49.583366 #21714] INFO -- : Perform TeacherBirthdayJob I, [2017-11-11T07:30:49.695109 #21714] INFO -- : Finished TeacherBirthdayJob in 0.11 seconds I, [2017-11-11T07:32:01.586710 #21769] INFO -- : Perform TeacherBirthdayJob I, [2017-11-11T07:32:01.725813 #21769] INFO -- : Finished TeacherBirthdayJob in 0.14 seconds I, [2017-11-11T07:35:37.642675 #21929] INFO -- : Perform TeacherBirthdayJob I, [2017-11-11T07:35:37.783441 #21929] INFO -- : Finished TeacherBirthdayJob in 0.14 seconds I, [2017-11-11T07:36:13.687404 #21955] INFO -- : Perform TeacherBirthdayJob I, [2017-11-11T07:36:13.824727 #21955] INFO -- : Finished TeacherBirthdayJob in 0.14 seconds I, [2017-11-11T07:36:49.663363 #21982] INFO -- : Perform TeacherBirthdayJob I, [2017-11-11T07:36:49.811763 #21982] INFO -- : Finished TeacherBirthdayJob in 0.15 seconds I, [2017-11-11T07:37:25.681799 #22010] INFO -- : Perform TeacherBirthdayJob I, [2017-11-11T07:37:25.821417 #22010] INFO -- : Finished TeacherBirthdayJob in 0.14 seconds I, [2017-11-11T07:38:01.682282 #22036] INFO -- : Perform TeacherBirthdayJob I, [2017-11-11T07:38:01.795722 #22036] INFO -- : Finished TeacherBirthdayJob in 0.11 seconds I, [2017-11-11T07:38:37.722369 #22063] INFO -- : Perform TeacherBirthdayJob I, [2017-11-11T07:38:37.868257 #22063] INFO -- : Finished TeacherBirthdayJob in 0.13 seconds I, [2017-11-11T07:39:13.735050 #22089] INFO -- : Perform TeacherBirthdayJob

ps. This is a mutiple Job

Crono.perform(AccountSyncJob).every 1.minutes Crono.perform(TeacherBirthdayJob).every 1.day #, at: '07:30'

gastongouron commented 7 years ago

I encountered the same problem with rake task, could you find any workaround? @shenhf

shenhf commented 7 years ago

@gastongouron Try to truncate crono_jobs table before start crono. You can use 'database_cleaner' gem. And in cronotab.rb, add : DatabaseCleaner.strategy = :truncation, {:only => %w[crono_jobs]} DatabaseCleaner.clean

PS. This is not working solution . This gem has serious problem. After days of running, It turned to be uncontrollerable!!