Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop Heroku Dyno that is running a Rails task through Heroku Scheduler?

Heroku Scheduler uses a One-off Dyno to run the scheduled task. That dyno doesn't appear in Heroku Dashboard, but it's there. How can I restart it, or temporarily stop it?

like image 800
Arslan Ali Avatar asked Aug 11 '16 13:08

Arslan Ali


People also ask

How do I stop Heroku workers?

To view and modify your app's dyno settings, you can use the Heroku CLI. * Running ps:stop on dynos that are part of a scaled process will automatically be restarted. In Private Spaces, ps:stop will terminate and replace the dedicated instance running the dyno(s). To permanently stop dynos, scale down the process.

Is Heroku scheduler reliable?

Reliable delivery Heroku Scheduler is a free add-on, but it doesn't guarantee that jobs will be executed at their scheduled time, or at all for that matter. While it is rare, the possibility that a job may be skipped or run twice does exist.


3 Answers

To stop a scheduled task, find its ID with:

heroku ps

=== scheduler (Free): bundle exec rake myraketask (1)
scheduler.7114: up 2019/02/24 14:50:36 +1100 (~ 24m ago)

=== web (Free): bin/rails server -p $PORT -e $RAILS_ENV (1)
web.1: up 2019/02/24 14:58:53 +1100 (~ 16m ago)

In the above, scheduler.7114 is the scheduled task ID.

Stop it with:

heroku stop scheduler.7114

Other useful notes

If you need to restart it:

heroku restart scheduler.7114

Or if you need to kill it (e.g. if you see a R16 -Detached error):

heroku kill scheduler.7114
  • Note the difference between kill and stop is that stop will stop it gracefully, whereas kill will not
like image 195
stevec Avatar answered Oct 24 '22 10:10

stevec


If you have the command line tools installed, heroku ps will list all the running processes, and you can use ps:kill or ps:restart to manage any of them.

heroku help ps will give you more details.

like image 27
eugen Avatar answered Oct 24 '22 09:10

eugen


You do not need to restart or stop. There are no dynos on Heroku dashboard, but you can find your scheduler in Heroku Scheduler dashboard.

You can set your schedulling tasks with running time you want and dyno plan.

When the time you set come, heroku scheduler dyno is started. After finishing the work, dyno is killed.

If you want to run manually, just call heroku run rake xxxx command.

like image 24
Jaehyun Shin Avatar answered Oct 24 '22 09:10

Jaehyun Shin