Cron job clarification
rob8624
HOBBYOP

3 months ago

Hi, despite reading the docs i need clarification on how to use CRON service. I have a Django backend service up and deployed using a custom Docker file, I need to delete some objects every 24hrs.

So, i wrote a Django management command,………do i need to make a new service in my project and add this to my start command, or do i add it to my existing backend service's start command (currently empty as start is handled by docker CMD)

I understand how to add the CRON services via service settings, but just need clarification on where to add the management command.

Project ID: N/A

Solved

7 Replies

3 months ago

Hey, you'll need to create a new service separate from your API to setup the cron job with the startup command.


rob8624
HOBBYOP

3 months ago

Cool, ok. So new service pointing to my repo?


3 months ago

Exactly, you can use the same repository/code, just change your startup command to run the cron job instead of your backend


rob8624
HOBBYOP

3 months ago

Ah cool, so no need to run Gunicorn? Or from current docker file? Does the start command over rule docker command? Sorry, slowly understanding 😀


3 months ago

Yep, no need for Gunicorn, and Railway will override your Dockerfile start up command


3 months ago

You might get some shell issues when trying to overriding your Dockerfile command, but changing your startup command to be sh -c " will solve any issues that you might get.


rob8624
HOBBYOP

3 months ago

Ok, thanks for the help, as always much appreciated 👍


Status changed to Solved passos 3 months ago


Loading...