R
Railway8mo ago
kb

Using Cron instead of scheduling in code

Im using node-schedule to do the following in my code;
schedule.scheduleJob("*/15 * * * *", async () => {
await runStuff()
});
schedule.scheduleJob("*/15 * * * *", async () => {
await runStuff()
});
but just noticed the Cron Schedule on railway settings, could I do away with the scheduler-in-code stuff with this, and just my code self executes runStuff() - or am i misunderstanding the cron stuff on railways side of things
Solution:
yeah I think you got the understanding down, remove the node-cron stuff from your code and have your code start the runStuff() function when it starts, and then exit when done, and railways scheduler will run the set start command on your set schedule
Jump to solution
5 Replies
Percy
Percy8mo ago
Project ID: 93709d46-9f33-4a5b-8651-5e9565510c7c
kb
kb8mo ago
93709d46-9f33-4a5b-8651-5e9565510c7c I think im asking if the cron schedule will just re-run my index file, or if it like invokes a whole new build or something
Solution
Brody
Brody8mo ago
yeah I think you got the understanding down, remove the node-cron stuff from your code and have your code start the runStuff() function when it starts, and then exit when done, and railways scheduler will run the set start command on your set schedule
kb
kb8mo ago
great - that makes sense. ill give it a try now i know im on right path, thanks!
Brody
Brody8mo ago
no prob!
Want results from more Discord servers?
Add your server