Using Cron instead of scheduling in code
kieron
PROOP

2 years ago

Im using node-schedule to do the following in my code;

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

5 Replies

kieron
PROOP

2 years ago

93709d46-9f33-4a5b-8651-5e9565510c7c


kieron
PROOP

2 years ago

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


brody
EMPLOYEE

2 years 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


kieron
PROOP

2 years ago

great - that makes sense. ill give it a try now i know im on right path, thanks!


brody
EMPLOYEE

2 years ago

no prob!


Loading...