a year ago
Hi! I'd like to run some Django commands regularly via a cron job.
I have one script that runs every 15 minutes, and several which run daily at different times.
I would ideally like to have a single instance, which knows which cron job has called it.
Is there any way to find out the cron command which called it, or even better, to name each cron job and pass that as a parameter? I know I can check the time, but that would mean configuring in multiple places.
If it's not possible, it would be a great feature to have.
Thanks!
6 Replies
a year ago
You would want to have a new Railway service for every job you need to run, and then you can set the start command in the service settings and whatever flags you want on that start command.
a year ago
Thank you! I want to avoid multiple services, though. It seems it’s not possible currently. The solution I’ve decided on is to run a single service regularly and check the time, effectively duplicating the cron functionality.
a year ago
May I ask why you want to avoid multiple services? there is no cost associated with simply having the service, and if you use Railways cron scheduler you only pay for the resources used whenever the task runs.
a year ago
I have 4 different tasks which perform almost identical operations which can be defined by a single variable. So I’d rather have them represented as something like a crontab file or set of env vars, rather than manually creating and maintaining many services.
a year ago
I'm going to run this in a single service, driven by env var configuration, instead of using cron and manually duplicating services for every entry: https://github.com/jhud/railway-scheduler
So my configuration looks like this:
SCHEDULE=[
{"time":"08:30", "job": "get", "param": "https://www.google.com/api/foo/"},
{"time":"09:30", "job": "get", "param": "https://www.blah.com/api/bar/"},
] python main.py
I would love it if Railway cron could just give me that one extra parameter next to the cron config, then I could get rid of the scheduler looping and this custom scheduling code.
Status changed to Solved brody • over 1 year ago