Configuring Cron Jobs?
So I'm running a cron job I wrote in my app like this
Now I have a seperate service on railway pointing to this one file and running it. I also noticed railway has its own cron scheduler. Do I also have to configure that along with this or is it fine to just leave the service running assuming that the cron job running internally will just run as scheduled?
5 Replies
Project ID:
f0e06b4d-4d9e-4d8d-a668-01321847d526
f0e06b4d-4d9e-4d8d-a668-01321847d526
you can use node-cron (or similar packages) or railway cron, but never both
railway cron re-deploys your service on the set schedule, if you are also running your own cron in code railway will never be able to re-deploy your app since its always running making railway cron pointless in this scenario.
theres nothing wrong with node-cron, you just shouldnt use both technologies.
for absolute cost effectiveness you can modify your code to just run the
await prisma.event.deleteMany();
once when you run the code and then exit, then use railway's cron this way your app will only be alive and consuming resources for as long as it takes to do that task, node-cron keeps the app running 24/7.that is an extremely great point I will probably do that
i figured that was the case just wanted to make sure
thanks so much!
no problem!