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•2y ago
Project ID: N/A
Marcelo Moura
Marcelo MouraOP•2y ago
N/A
Brody
Brody•2y 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 MouraOP•2y ago
really? why not? I got it with a friend and it is working (without the cron part). is something wrong?
Brody
Brody•2y 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 MouraOP•2y 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•2y ago
very wrong
Marcelo Moura
Marcelo MouraOP•2y 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•2y ago
bruh you can't use code from the question itself
Marcelo Moura
Marcelo MouraOP•2y ago
i took what i could LMAO
Brody
Brody•2y ago
railway has no native cron scheduler, you would need to use the schedule python library in code
Marcelo Moura
Marcelo MouraOP•2y ago
so I would do it within the main script? with the schedule module
Brody
Brody•2y ago
correct
Marcelo Moura
Marcelo MouraOP•2y ago
thanks 🙂 are you related to the railway owners? or a community contributor?
Brody
Brody•2y ago
my dad is the owner of railway
Marcelo Moura
Marcelo MouraOP•2y ago
huh really
Brody
Brody•2y ago
no
Marcelo Moura
Marcelo MouraOP•2y ago
._.
Brody
Brody•2y ago
just a community member
Marcelo Moura
Marcelo MouraOP•2y ago
ask them for money for helping the members 😮
Brody
Brody•2y ago
they give me 1$ for every thread I solve
Marcelo Moura
Marcelo MouraOP•2y ago
I tried: schedule.every().hour.do(zera_consultas) but i dont think it is working =/ have i done something wrong?
Adam
Adam•2y ago
that looks fine to me. Why don't you think it's working? Have you tested it locally?
Marcelo Moura
Marcelo MouraOP•2y 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