WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 7 years ago

#17888 closed defect (bug) (worksforme)

Problems with build in Cronjob Schedule - is this a bug?

Reported by: 1manfactory Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1.3
Component: Cron API Keywords:
Focuses: Cc:
PR Number:

Description

I have programmed a pluging (Emu2 - Email Users 2) to send out mails to users/groups. It's still beta but the main functions work.

Now I added a feature for a digest of the newest posts to be sent out once a day controlled by the build in scheduler.

I do the following:

# plan the scheduler
 add_action('EMU2_task_hook', 'EMU2_send_scheduled');

where EMU2_send_scheduled is the function sending all the mails. This is working.

wp_clear_scheduled_hook('EMU2_task_hook');
 wp_schedule_event( strtotime( $schedule_time ) - get_option('gmt_offset') * 3600 , 'daily', 'EMU2_task_hook' );

Where $schedule_time is set by the user, e.g. "23:15" for mails to be sent at 11:15 pm.

This works, I checked it with wp-crontrol.

But now come the problems.

Some of the users which downloaded my plugin reported strange behaviors with the scheduled mails send out every hour instead of only once a day. Or with mails send three times in a row.

I first thought they did something wrong. But after a few days of stable work it happened to me as well (Online, less than 10 users, Linux)

I am using/testing this on 5 installations, online and offline, on different hosts and systems (Windows/xampp and Linux). Some work today, but they fail the next day with sending two or even three mails at once, i.e. starting the job two/three times.

I have no clue what is going on.

Is this a bug? Is this caused by interferences with other schedules or plugins?

Change History (6)

#1 @scribu
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Please use the support forums or wp-hackers for figuring out if this is a bug with core or not.

If you're positive it's not caused by some other plugin or your own code, feel free to re-open this ticket.

#2 @1manfactory
8 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

OK,
I deactivated EVERY plugin except my own.
And again the error only sometimes occurs, which is really stressing.
From what I heard from others is that they also only have irregular problems with my plugin.
I installed this - as written above - on different environments. And the problem consists.
I don't know what else to do. There is no clear sign for me why it sometimes works and sometimes not.
It smells like a bug.
Besides: I already posted this in the support forum some days ago. Nobody answered.

#3 @petervanderdoes
8 years ago

I never thought much about it but I have a similar issue with one of my plugins. It should run once a day to clean out a DB table and every now and then the cron job runs twice.
It's been happening for a while now, I mean at least a year if not two, so it's not related to a certain WordPress version. I will see if I can write some debugging stuff around my cron job and see what's happening.

#4 @dd32
8 years ago

A few notes:

  • The cronjob may not be called at the exact point in time specified. The cron system relies upon a user visiting the site to kick the cron off, for example, if there are no visitors between 1pm and 9pm, and a job was scheduled at 6pm, it'll run at 9pm.
  • The Cron system "often" runs into issues related to running twice due to the locking not "working" 100% of the time.
  • See the open Tickets related to Cron - I believe all the issues you've outlined above are mentioned in some of those tickets.

#5 @nacin
8 years ago

  • Keywords close added
  • Milestone set to Awaiting Review

#6 @SergeyBiryukov
7 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from reopened to closed

No traction in 19 months.

There were some changes to cron in 3.3 and 3.4: #17462, #19700, #19818.

Feel free to reopen with more information if there's still a problem.

Note: See TracTickets for help on using tickets.