Heroku - DO CRON jobs keep working when the app is "asleep"? Heroku - DO CRON jobs keep working when the app is "asleep"? heroku heroku

Heroku - DO CRON jobs keep working when the app is "asleep"?


When the time comes for the app to sleep Heroku sends the SIGTERM signal to the process which will most likely kill the process in your case, preventing the cron jobs from running. It is possible to catch and ignore the SIGTERM signal but Heroku will in that case probably just forcibly shut down your process using the SIGKILL signal, like it does when restarting dynos.

One possible workaround is to use the New Relic addon to regularly ping/monitor a URL in your app, preventing it from sleeping. However, using this approach together with node-cron could be problematic since Heroku restarts all dynos at least once a day. If the restart occurs when the cron job would trigger it might not trigger the cron job that day.

Another possibility is to instead of using node-cron use the Heroku Scheduler addon to run your periodic tasks.