Cronjob on Flask App

kblumbergHOBBY

3 months ago

I have a Python flask app deployed.

I would like to call a function within the app every hour. I see the cron scheduler, but not a way to specify the command (e.g. python scripts/update_tweets.py)

Is there a way to accomplish this? Or should I expose an endpoint that then calls this script?

Solved

3 Replies

3 months ago

How does your flask app and update_tweets.py communicate? Ideally, it is through a database, so the cron job can just update the values which are being served by your flask app. In this case, you would want to deploy another service using the same flask repository, specify a cron schedule and set python scripts/update_tweets.py as your custom start command.

Cron jobs docs: https://docs.railway.com/reference/cron-jobs
Start command docs: https://docs.railway.com/guides/start-command


kblumbergHOBBY

3 months ago

Gotcha, thank you!

Is there any way to have multiple cron jobs on the same service?


kblumberg

Gotcha, thank you!Is there any way to have multiple cron jobs on the same service?

3 months ago

No, you can only specify one cron job for one service.


Status changed to Solved uxuz 3 months ago