0

If I scheduled a CPU-intensive job via a cron scheduled event, how do I go about stopping it or cancelling the job while it is currently running?

  • Is this a one-time thing or would you like to be able to cancel a cron event from somewhere on a regular basis, perhaps from another PHP script? – kovshenin Sep 4 '15 at 11:28
1

Removing / un-scheduling obsolete cron jobs can be achieved using this code snippet.

add_action("init", "remove_cron_job"); function remove_cron_job() { wp_clear_scheduled_hook("my_schedule_hook"); }

Change the my_schedule_hook to cron’s hook name and add the code in your theme’s function.php file.

  • but this won't stop the job that's currently running. – Jürgen Paul Sep 5 '15 at 7:54
  • Also wondering if this is possible (stopping the currently running cron) – atwellpub Mar 9 '17 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.