question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to kill a scheduled cron job ?

See original GitHub issue

I’m curious if I have a rest API that creates and schedules a cron job.

How could I cancel this cron job at a future point? Considering the reference to the job is now out of scope when I want to cancel it.

` I can start it but I can’t end it…

    var cronJob = CRON.job(frequency, function()
     {        

            updateFeedbackJob()
            .then(result =>
             {
                    printMessage("updateFeedbackJob()-> finished");
            })
             .catch(err =>
            {
                   printMessage("updateFeedbackJob()-> failed");
                    printObject(err);
            });
    });
    cronJob.start();

`

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
iamakshatjaincommented, Dec 29, 2019

how do I store the cron jobs to the database to kill it later?

1reaction
ncb000gtcommented, Feb 27, 2019

@kamleshkarwande You get the reference to the job in two ways. Either by setting a variable when instantiating var a = new Job() and then calling a.stop() via a closure or something else OR by not using an arrow function for the onTick in which case the scope of the function should be the job.

Hope that helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to stop a currently running cron job? - Super User
First type ps aux to see what all processes are running. Then note down the PID of each process you want to stop....
Read more >
How can I see/stop current running crontab tasks? - Ask Ubuntu
Firstly, use only one command per line in crontab. Change this crontab line: 00 10 * * * /usr/bin/wget LINK ; shutdown -h...
Read more >
Kill all currently running cron jobs - Server Fault
To kill all processes for the user, you have a few options. I like: su - username then kill -9 -1. To see...
Read more >
how to cancel the time scheduled cron job in java?
By using above code i can able to schedule cron job..but if want cancel the schedule time how can able to cancel or...
Read more >
job schedule cron delete - Product documentation - NetApp
The job schedule cron delete command deletes a cron schedule. Use the job schedule cron show command to display all current cron schedules....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found