profile
viewpoint

Ask questionsStopping a cron after one-time execution

If I set a job to run once, do I need to do any cleanup? Like, do I need to call job.stop() at any point?

Here's my job:


  const date = new Date()

  date.setMinutes(date.getMinutes() + 5)

  const job = new CronJob(date, function () {
      // do stuff here
  })

  job.start()

The job will run 5 minutes from now, which is what I want. Just curious if I NEED to call job.stop() at some point in the future

kelektiv/node-cron

Answer questions matthiasbaldi

I don't know if you have to call the stop() method. But why do you create not just a simple method with a setTimeout? would be do the same thing isn't it? In my understanding a cronjob is something which runs multiple times.

useful!

Related questions

Something went wrong. cron reached maximum iterations hot 1
source:https://uonfu.com/
Github User Rank List