-
-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cron jobs not getting run #519
Comments
@dehjli85 Thanks for opening an issue. Cron runs its own timer and then enqueues a job at the time it's triggered. So for your example, the job would be enqueued at 9am sharp. To debug it, could you changing some values to run locally: GoodJob.on_thread_error = -> (exception) { puts "GOOD_JOB ERROR: #{exception}\n #{exception.backtrace}" } And then change the cron value to something like |
Ah ok, great to know. I'm gonna try this out in a little bit and report back if things look ok. |
Ok, I followed your suggestions on changing the cron to run every 10 seconds, and was able to confirm that every 10 seconds a new row would appear in the table. However, when I changed it back to the Thoughts on whether time zone needs to be specified in a certain way? |
@dehjli85 that's good progress. If you open up Rails console, you could debug the cron string with: GoodJob::CronEntry.find(:email_every_day).next_at That will give you a |
btw, It looks like the timezone parsing will either use the local timezone of your Rails app, or you can give it one explicitly: [41] pry(main)> Time.zone.to_s
=> "(GMT+00:00) UTC"
[42] pry(main)> Fugit.parse('every day at 9am').next_time.to_t
=> 2022-02-15 01:00:00 -0800
[43] pry(main)> Time.zone = "America/Los_Angeles"
=> "America/Los_Angeles"
[44] pry(main)> Fugit.parse('every day at 9am').next_time.to_t
=> 2022-02-15 09:00:00 -0800
[45] pry(main)> Fugit.parse('every day at 9am UTC').next_time.to_t
=> 2022-02-15 01:00:00 -0800
[46] pry(main)> Fugit.parse('every day at 9am America/Los_Angeles').next_time.to_t
=> 2022-02-15 09:00:00 -0800 |
It looks like this is a time zone issue. Something funky is definitely going on here... If I do the following in the initializer:
This is the output I get from the CronEntry statement: So the timezone offset ( The date is also a day later, ( For reference, in the console if I run
so maybe this is an issue with |
aha, it looks like fugit wants a space between the numbers and the [5] pry(main)> Fugit.parse('every day at 4:30 pm America/Los_Angeles').next_time.to_t
=> 2022-02-16 16:30:00 -0800 |
🤦♂️ . Yup... that looks to be it. I think we can close this issue out. I'm surprised I will say the Excited to keep trying this gem out! |
@dehjli85 I'd appreciate it if you could expand the Cron section of the readme. Thanks! |
We're looking at using
good_job
to replacedelayed_jobs
in our app, but I'm running into issues getting the cron jobs to run. It looks like when I start upgood_job
, that the cron jobs get created, because I see the following in the terminal:I, [2022-02-10T15:25:46.210058 #89389] INFO -- : GoodJob started cron with 1 job.
But when the time comes actually run the job... nothing happens. Furthermore, when I look at the
good_jobs
table, nothing is there. This may be a point for clarification, but I assumed that if a cron job gets scheduled, I should expect to see it in thegood_jobs
table with thescheduled_at
column filled out with when the job is supposed to run. Does that still happen with cron jobs?For what it's worth, if I use the rails console to run my job using the
perform_later
method, it adds an entry into thegood_jobs
table, and executes the job as I expected, so jobs not depending on cron seem to be fine. Is there something I'm missing here?Here's my relevant
application.rb
code:I'm running this on a Rails 5.2 app, ruby 2.7.5 if that makes any difference.
The text was updated successfully, but these errors were encountered: