node-cron icon indicating copy to clipboard operation
node-cron copied to clipboard

Cron job got executed twice on Azure Web App

Open brechtarnou opened this issue 4 years ago • 4 comments

Hi all,

My cron job gets executed twice on my azure web app.

image

Even a simple console.log('hi'), gets executed twice. Anyone knows what this could be?

Kind regards, Brecht

brechtarnou avatar Dec 07 '20 18:12 brechtarnou

Maybe you have 2 instances?

davidlane-iteratec avatar Dec 17 '20 22:12 davidlane-iteratec

Have you resolved this issue @brechtarnou . I am also facing the same issue on AWS.

NareshKukreti12 avatar Apr 18 '22 05:04 NareshKukreti12

Maybe you have 2 instances?

I am also facing the same. On local server this is working perfectly, but after deploying on AWS the cron triggering twice . I have multiple crons running in the project and each cron is running twice. DON'T know how to resolve this

NareshKukreti12 avatar Apr 18 '22 06:04 NareshKukreti12

@NareshKukreti12 @brechtarnou not sure if you are still facing this issue. I recently ran into this after deploying app to Azure web and resolved the problem by fixing the number of instances - inspired by @davidlane-iteratec's comment. In my case, turned out that the app had been set to default to 5 instances constantly. Reducing to one instance stopped the issue immediately.

Alternatively, if you prefer to keep >1 instance for performance optimization, try leveraging autoscale to dynamically control the number of instances - this has effectively resolved the issue for me

Might be something similar on AWS? @NareshKukreti12

mandyGitH avatar Jun 11 '22 20:06 mandyGitH