node-cron / node-cron

A simple cron-like job scheduler for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

two cron sometime not work

Alice-Thirty opened this issue · comments

There are two cron task and they use the same function.
I want to lock the other cron task when one of all cron task work.

Sometimes, the cronForecastWeather_ not work. Instead cronForecastWeather_ work.

status like this

00:05 cronCurrentWeather_ work
00:10 cronForecastWeather_ work
00:15 cronCurrentWeather_ work
00:20 cronCurrentWeather_ work
00:25 cronCurrentWeather_ work

I expect this
status like this

00:05 cronCurrentWeather_ work
00:10 cronForecastWeather_ work
00:10.1 cronCurrentWeather_ work

this.cronCurrentWeather_ = new CronJob(
    '*/5 * * * * *',
    this.update.bind(this, 'current'),
    null,
    true);

  this.cronForecastWeather_ = new CronJob(
    '*/10 * * * * *',
    this.update.bind(this, 'forecast'),
    null,
    true);


private update(weather: string): void {

  this.cronCurrentWeather_.stop();
  this.cronForecastWeather_.stop();
  /* to do something*/
  this.cronCurrentWeather_.start();
  this.cronForecastWeather_.start();

};

Same issue, can we get some support ?