[Django]-How to implement simple cron job with Heroku and Django

1👍

First, if Scheduler runs on a self-contained dyno, how can it make a call to Django’s manage.py file?

When you upload (push) your project, it is compiled into a slug. This slug is distributed to every dyno that is running your web app, and every 1 off dyno as well. This means that there will be a copy of manage.py on every dyno that you run, either through scheduler, or the heroku run command.


Second, how many dyno-hours does a Scheduler task usually take up?

Scheduler add-on runs one-off dynos that will count toward your dyno-hours that you will be charged for each month.


If the task only takes 30 seconds to run, for example, am I only billed for 30 seconds of usage, or are there more costs associated with spinning up (and then down) the dyno?

Any time spent executing a one-off dyno will contribute to usage and will be charged just like any other dyno.

This means that using 30 seconds for a task takes 30 seconds of dyno time (REF). I don’t believe that you’re charged for spin-up/spin-down time, but you will be charged for the time that python takes to load your app to the point that it can run your management command, so try to keep your app as light as possible in terms of boostrap time.

👤Thomas

3👍

Actually, you can try APScheduler instead.

It allows even 1 minute period task and is totally free.

You just have to define the clock process and turn on the clock.

You can see the step-by-step tutorial on the page.

👤mhchia

Leave a comment