The MU forums have moved to WordPress.org

WP Cron creating sql queries over 100,000 characters (5 posts)

  1. ninnypants
    Member
    Posted 14 years ago #

    I'm using wp_schedule_event() to add items to wp-cron but they seem to be constantly adding additional instances of the event every time the site is loaded or at least that is what this sql query leads me to believe http://docs.google.com/View?id=d6csj54_11cp8jdpfw

    Code:

    wp_schedule_event(time(), 'twicedaily', 'work_paid_listings');
    wp_schedule_event(time(), 'daily', 'clean_spam_users');

    Could this be because I'm using time() instead of a non changing integer?

  2. SteveAtty
    Member
    Posted 14 years ago #

    You only ever schedule something for cron once, or once per blog if required. Once its set that's it. So if its a plugin you need to put it the initialisation block, and don't forget to remove it in the plugin deactivation block as well

  3. ninnypants
    Member
    Posted 14 years ago #

    will this work with MU plugins? I haven't seen any way to turn MU plugins on or off other than removing the files

  4. SteveAtty
    Member
    Posted 14 years ago #

    If you're going to do it with a mu plugin then the best way would be to either use a blog option to make sure you only set it up once or use the wp_next_scheduled function to see if your job is scheduled for that blog and if not then schedule it

  5. tim.moore
    Member
    Posted 14 years ago #

    There's also WP-Crontrol, which I've found to be an excellent way to manage wp-cronjobs.

About this Topic

  • Started 14 years ago by ninnypants
  • Latest reply from tim.moore