I have experienced a problem in Heroku where initialize my Cronjobs (using Cron) in the app.js the problem is that my app runs in three dynos. This means that my cronjobs are initialized three times (one per dyno) and therefore the cronjobs are executed three times instead of one. Has anyone experienced this? Should i use a diffrent library?
I use node.js buildpack, thanks a lot!
You can avoid running multiple cron jobs by adding if else conditions in your code.
let dyno = process.env.DYNO;
if(dyno === "web.1"){
// perform task
}