R
Railway9mo ago
Ciatzo

Cron job to run script: Add separate service or not?

Hi, I have a website running on railway with django and a postgress database. I have a separate python script in the same repo as the Django project that updates the postgres database (that is also used by the main django project) with some external data. I want to run this script once a week, separately of the main service (which should always run). I saw you can use a cron job to schedule a job to run. However, if I add a cron job to my main service (which runs the website backend), it would run that service's start command instead. I could add a new service for running this job, but i'm not sure if I should add the same github repo twice as two separate services (that both run django to interact with the same postgress database service). What would be the recommended way to do this? Thanks in advance! Project id: b1e4979e-4e81-4258-ab74-dde97491a4ec
Solution:
two services from the same repo would be the correct way to go. on the cron service you would set the applicable start command so that the cron job runs the script
Jump to solution
7 Replies
Percy
Percy9mo ago
Project ID: b1e4979e-4e81-4258-ab74-dde97491a4ec
Solution
Brody
Brody9mo ago
two services from the same repo would be the correct way to go. on the cron service you would set the applicable start command so that the cron job runs the script
Brody
Brody9mo ago
make sure your script exits as soon as its done though
Ciatzo
CiatzoOP9mo ago
@Brody I see, thanks. When I set up the separate service, can I also manually run it (at some other time than the scheduled cron time)?
Brody
Brody9mo ago
yes a cron service gives you a run now button
Ciatzo
CiatzoOP9mo ago
Perfect, thanks so much (for the incredibly fast response as well!)
Brody
Brody9mo ago
no problem!
Want results from more Discord servers?
Add your server