Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to delayed job for simple cron task on heroku?

In my Rails app on Heroku, I want to execute a simple block of code at 5 specific times in the future (each about a day apart), down to the second.

Is there a good way to do this without a background process?

I don't want to use Delayed Job because it'll require a Worker instance that costs ~$30/month. Seems unnecessary.

Is there a GOOD way to do this without Delayed Job / a Heroku Worker?

Resolved

Thanks for your answers- looks like there isn't a solid way to accomplish this. Going with Delayed Job.

like image 857
bevanb Avatar asked Dec 02 '25 14:12

bevanb


2 Answers

use a rake task and heroku scheduler instead

https://devcenter.heroku.com/articles/scheduler

The scheduler add-on will run one-off processes that will count toward your dyno-hours for the month.

You could use a Rake task with the Heroku Scheduler, then add a bit of intelligent logic: sleep until job_is_available if job_is_available_in_less_than_twelve_minutes?

Then you're paying for the time to run the code, and the few seconds it takes your rake task to check if a job is available. Something like 1-3 dollars, since Heroku pro-rates to the second.

like image 44
nthj Avatar answered Dec 04 '25 05:12

nthj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!