Supercronic cron jobs with a Django app?

I’ve got a Django app running on fly.io that allows users to check out a product for X amount of time, then return it when they’re finished. The problem is that some users either forget to return the product when the time has elapsed, or intentionally keep it out longer. I’d like to remind users to return the product as follows.

  1. When X is checked out, add a new db record with an expected “return by” time.

    1. The time varies based on product: some might be 30 minutes, some might be 90, etc.
  2. If the user returns the product before the return by time, the record is marked as done.

  3. If the user has not returned the product within the allotted time, I email them to ask them to return the product.

I was originally thinking of using a queueing system like Celery, but there’s probably not going to be more than 20-30 users in this situation. So I was looking at a cron system and found Supercronic.

This sounds like exactly what I need, but I have a few questions. Can Supercronic call Django manage commands? if so then I could just set a cron to run every X minutes (5 minutes perhaps—precision isn’t terribly important here). It would call a Django command that checks the state of anything marked as “checked out”, with a timestamp older than the desired duration. It would then perform the task on any matching records?

Hi - it absolutely can. Use process groups as described here. Get a smallish machine to run Supercronic on. (that’s the only downside - the cron machine has to be running all the time). When it runs, it has the same app, configuration, commands, etc. as your main app machines.

  • Daniel

The above is a fine way to do it. Just to give you some choice, you can often use hosted CI to make cron calls e.g. via an SSH command or HTTP call. GitHub supports this, for example, as long as you don’t mind trigger times being accurate to within a few minutes.