0

I created a cron job with node cron, for now the job is really simple:

module.exports.start = async ( args ) => {  
  console.log("start cron");
  // every 5 minutes
  CronJob.schedule('*/5 * * * *', () => {
    chatLog.send("A text log sent with telegram bot");
  });
}

Now for the third day I've noticed that the cron works like a charm all day long but suddenly stop during the night a 1 o'clock.

In the morning when I start working the cron starts again.

My app is based on express framework and hosted on a plesk server with phusion passenger extension.

Now I suspect that in the night the server stop working, and that a restart happen in the morning at the first api call. Is it possible? Or do you think that I'm missing something...

Tnx

red
  • 1,529
  • 1
  • 12
  • 33
  • 1
    I face the same issue with node-cron bcz of some memory leak I think node-cron is not stable there are many open issues in this library. I can suggest croner (https://www.npmjs.com/package/croner) which is much better and more stable than node-cron and its collaborator are pretty active if you raise any issues. – Muhammad Fazeel Feb 09 '23 at 08:25
  • Tnx, croner seems interesting, but it's really strange that the stop happen at the same time every day. I suspect that the issue is more related to plesk, but if I won't find evidence that confirm my idea I will try to use croner. – red Feb 09 '23 at 08:36
  • is it throwing any error in your case or just stop working? – Muhammad Fazeel Feb 09 '23 at 08:42
  • Just stop working, and the restart happen automatically during my first api call, like when the app is manually restarted – red Feb 09 '23 at 08:49
  • do you use a timezone option somewhere in your node-cron ? – Paul-Marie Feb 09 '23 at 09:02
  • No timezone used – red Feb 09 '23 at 09:29

0 Answers0