• Resolved LELF

    (@eldredge)


    Hello,

    I was hoping your plugin would allow me to delete duplicate cron jobs with the name ‘wp_privacy_delete_old_export_files.’ I have over 1800 schedule cron events with the same name. Some have the same date, whereas others do not. I just need one ‘wp_privacy_delete_old_export_files’, not 1800 of them. Do you know how I can safely delete these extra jobs?

    They all say, ‘One or more cron events have missed their schedule.’

    I have researched for an answer, any help would be appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    You can do this from the list of actions available when you hover your mouse over each event in the list. One of the options is “Delete all events with this hook”.

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Oh this option might not be available for the cron events that WordPress provides because normally they cannot be deleted.

    I think this isn’t possible at the moment. If you have access to WP-CLI then you can do it with the wp cron event delete command. Details here: https://github.com/wp-cli/cron-command#wp-cron-event-delete

    Thread Starter LELF

    (@eldredge)

    Hello @johnbillion, will this be a future option? Because wow, I am not even sure why it has added this many. I just learned about WordPress Cron two days ago, because Updraft stopped working and gave me error messages. Saying I have too many Cron events scheduled that have not been completed, or something like that.

    Thank you

    Jennifer

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Yeah I’ll likely add this as an option. Currently you cannot delete cron events that are added by the WordPress core software because they immediately get created again. But it makes sense to allow duplicates like this to be deleted.

    Hi @johnbillion,

    I’m also having this kind of issue, don’t know why as I followed all guidelines. For some fucked up reason, I still have some cron tasks duplicating (my cron jobs are automated from linux cron using wp-cli).

    It’ll be nice to have a php argument which tells that a cron job can’t be duplicated (like duplicate=false which would make the name unique and set it to true by default ) ?

    I’m not using wp cron event delete as this will delete all events while I just want to avoid duplicates …

    I’m stuck with this issue for years …

    Have a nice day ??

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    I just released version 1.6 which contains, among other things, a change which means you can now delete events that are added by WordPress core when there’s more than one of them.

    Hi @johnbillion,

    Just testing it … I’ll give you my feddback ??

    Just to know, what are you doing to delete duplicates ? (in php I mean)

    Just to explain my situation, I built a plugin to publish my posts … This is the way I declared my schedule :

    if?(?!wp_next_scheduled(‘publish_posts’,?array(‘noduplicate’)?)?)?{
    wp_schedule_event(?time(),?‘hourly’,?‘publish_posts’,?$args?);
    }
    add_action(‘publish_posts’,?array($this,?‘publishPosts’)?);

    I’ve disabled default cron and running it via cron tasks in linux.

    For some reason, the task is duplicating for some domains, not for others … So I’d like to find a way to avoid this.

    Anyway, I’m using your plugin for a while and it’s clearly the best one to manage cron jobs. Thank you ??

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Behind the scenes, WP Crontrol calls the wp_unschedule_hook() function in WordPress which unschedules all events for the given hook. It doesn’t do any duplicate detection (except to count the number of events with a hook in order to show the “Delete all events with this hook” link).

    Regarding duplicate events being created, I would check that you’re 100% sure the $args being passed to both wp_next_scheduled() and wp_schedule_event() is identical.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to delete duplicate cron jobs with the same name?’ is closed to new replies.