R
Railway•16mo ago
Marcelo Moura

Cron job to schedule Python script

I successfully deployed my main application script as a API, but now I would also like to schedule some cron jobs to run python scripts. What am I doing wrong? It is not working for me. This is my railway json file: { "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "NIXPACKS" }, "deploy": { "startCommand": "python application.py", "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 10 }, "cron": { "job": "0 0 * ? * ", "command": "python zera_consultas.py" }, "cron": { "job": "0 0 ? * *", "command": "python desbloqueia_usuarios.py" } }
24 Replies
Percy
Percy•16mo ago
Project ID: N/A
Marcelo Moura
Marcelo Moura•16mo ago
N/A
Brody
Brody•16mo ago
I'm curious as to how you came up with this railway.json file, because that is not a valid config
Marcelo Moura
Marcelo Moura•16mo ago
really? why not? I got it with a friend and it is working (without the cron part). is something wrong?
Brody
Brody•16mo ago
the cron stuff isn't valid, there's nothing relating to cron that you can configure in the railway.json file what made you think that the cron stuff was valid?
Marcelo Moura
Marcelo Moura•16mo ago
oh! damn 😦 is there any way to schedule in railway app then? I got it on a stackoverflow post, but is wrong apparently =[
Brody
Brody•16mo ago
very wrong
Marcelo Moura
Marcelo Moura•16mo ago
Stack Overflow
Error creating cron job for Python script on Railway
I'm trying to run a Python script on Railway.app, every 30 seconds, but it's not working. I tried with the codes below inside my project, but it seems to me that there is something wrong that doesn't
Brody
Brody•16mo ago
bruh you can't use code from the question itself
Marcelo Moura
Marcelo Moura•16mo ago
i took what i could LMAO
Brody
Brody•16mo ago
railway has no native cron scheduler, you would need to use the schedule python library in code
Marcelo Moura
Marcelo Moura•16mo ago
so I would do it within the main script? with the schedule module
Brody
Brody•16mo ago
correct
Marcelo Moura
Marcelo Moura•16mo ago
thanks 🙂 are you related to the railway owners? or a community contributor?
Brody
Brody•16mo ago
my dad is the owner of railway
Marcelo Moura
Marcelo Moura•16mo ago
huh really
Brody
Brody•16mo ago
no
Marcelo Moura
Marcelo Moura•16mo ago
._.
Brody
Brody•16mo ago
just a community member
Marcelo Moura
Marcelo Moura•16mo ago
ask them for money for helping the members 😮
Brody
Brody•16mo ago
they give me 1$ for every thread I solve
Marcelo Moura
Marcelo Moura•16mo ago
I tried: schedule.every().hour.do(zera_consultas) but i dont think it is working =/ have i done something wrong?
Adam
Adam•16mo ago
that looks fine to me. Why don't you think it's working? Have you tested it locally?
Marcelo Moura
Marcelo Moura•16mo ago
ok i understood how it works now thanks how do I mark this as solved?
Want results from more Discord servers?
Add your server