Cron job doesn't stop
opened this issue · comments
Hello, I have started a cron job when a certain condition meets in the code. When I'm trying to stop the cron job, it doesn't stop. I have written a code like this. Can you please check if there is something wrong with my code or if there's bug in the lib?
I debugged this, and found that even after task.stop(), it keeps on running cron job every two minutes. How to kill it?
task = cron.schedule('*/2 * * * *', () => {
if (token && task) {
// If the token is already generated by another service, kill the task.
task.stop();
task = undefined;
} else {
util.logMessage('Trying to fetch token every two minutes.', 'info');
this.fetchToken();
}
});
I think you need to set the scheduled
option to false
to manually start the job.