cron.js icon indicating copy to clipboard operation
cron.js copied to clipboard

Clear cron job

Open ghost opened this issue 9 years ago • 9 comments

Hello. I need to delete cronJob object. How can i do it?

ghost avatar Apr 23 '15 09:04 ghost

I also need to do this.

knguyen2525 avatar May 01 '15 06:05 knguyen2525

I have create it from forked current cron.js. You can use it:https://github.com/farkhad-alizade/cron.js

ghost avatar May 01 '15 06:05 ghost

Thanks so much!

How would I stop it?

var job = new CronJob('*/10 * * * * *', function(){ console.log("please stop me"); });

I tried job.stop();

Thanks again

On Thu, Apr 30, 2015 at 11:26 PM, farkhad-alizade [email protected] wrote:

I have create it from forked current cron.js. You can use it: https://github.com/farkhad-alizade/cron.js

— Reply to this email directly or view it on GitHub https://github.com/padolsey/cron.js/issues/4#issuecomment-98057662.

knguyen2525 avatar May 01 '15 06:05 knguyen2525

just call stop method. job.stop(); Exactly!

ghost avatar May 01 '15 06:05 ghost

Hmmm, getting a job.stop is not a function.

var job = new CronJob('*/10 * * * * *', function(){ console.log("running"); job.stop(); });

Any ideas :(

knguyen2525 avatar May 01 '15 06:05 knguyen2525

are you sure u forked cron.js from my repository , not from @padolsey ?

ghost avatar May 01 '15 06:05 ghost

yes, I also ran through the cron.js code to make sure it had the stop logic.

knguyen2525 avatar May 01 '15 06:05 knguyen2525

Please, try this: var job = new CronJob('*/10 * * * * *', function(){ console.log("running"); }); job.stop();

ghost avatar May 01 '15 06:05 ghost

Same issue, BUT I just manually set job.events = [] and job.isStopped = true and that did the trick!

Cheers!

knguyen2525 avatar May 01 '15 06:05 knguyen2525