April 17, 2015 at 2:56 pm #15739
wp-cron is run from PHP CLI every half an hour.
Addidionally the “newsletter” event every 5 minutes from wp-cli:
/usr/local/bin/wp --quiet --url=http://www.***.hu/ --path=/home/***/public_pm2/server cron event run newsletter
After one or two days the “newsletter” event disappears. Listing wp-cron events does not show it.
Where could it be deleted?
Thank you.April 17, 2015 at 2:57 pm #15740
When logging into WP as an admin it is recreated.
Please advise.April 17, 2015 at 3:08 pm #15741
Yes it’s recreated because Newsletter doesn’t find it. Check if wp cli has that event active.April 17, 2015 at 6:32 pm #15746
> Check if wp cli has that event active.
What does it mean that wp cli has it event active?
This simply runs the “newsletter” event.
wp cron event run "newsletter"
I do not understand.April 17, 2015 at 10:50 pm #15749
Another user had problem with wp-cli and it told me he forgot to enable the newsletter event. I don’t know how wp cli works, anyway. The event should not disappear. Maybe another plugin is removing it? Try to install wp-control is a small plugin which shows the installed cron.April 17, 2015 at 11:13 pm #15753
The thing is wp-cli a WP console tool. It is able to list events.
Do you have any code in your plugin that removes that event?April 17, 2015 at 11:22 pm #15758
The plugin may remove the event only on deactivation. In the past there were a couple of user having the same problem. Try to check the server error log for php fatal errors or out of memory errors.April 18, 2015 at 1:58 pm #15761
I only have suhosin alerts (a PHP extension for security) but it is disabled for CLI.
Do you think a PHP error could remove the event from the database?April 18, 2015 at 2:14 pm #15763
Crons are not on database are runtime rescheduled by plugins. A fatal error while executing a cron or an out of memory can block wordpress to reschedule a periodic cron. Actually only debugging wp while executing a cron can help in finding the problem…April 18, 2015 at 3:58 pm #15764
Could you make the event fixed. I think it is a more WP-like approach.April 20, 2015 at 7:56 am #15788
I use the periodic even scheduling of wp, what do you mean with make it fixed?April 20, 2015 at 9:33 am #15793
You just mentioned
Crons are not on database are runtime rescheduled by plugins.
and I’ve missunderstood as “Crons anre not on database. (period)” But they are.
Now I understand that WP core fails to reschedule them:
A fatal error while executing a cron or an out of memory can block wordpress to reschedule a periodic cron.
Do you mean by “an out of memory can block wordpress to reschedule a periodic cron” that a not-rescheduled cron will disappear from the database?
I think it will stay sceduled for a time in the past. The entry itself won’t be deleted.April 23, 2015 at 12:37 am #15861
WordPress put into the database the next time and event (for example “newsletter” should be fired). When it fires it, since the event has a periodicity, it reschedule the event. WP has default intervals available (daily, hourly, …) and Newsletter adds it’s own.
This information is not on database, when the plugin is active it adds its interval to the list of the intervals listening to a filter. If this interval is not added (maybe activating the cron from “cli” does not let the plugin to load completely (I don’t know), WP may fail to reschedule the event. As far as I know, wordpress tries to guess when to reschedule it even if the interval definition is missing, using some event information… to find out the bug one should log what happens in the wp-cron.php and related function when the event is rescheduled.May 23, 2015 at 5:43 pm #16328
If someone is loking for a workaround
#!/bin/bash # # Keep sending newsletters. Restore schedule if missing. export WP_CLI_CONFIG_PATH="/home/***/public_pm2/wp-cli.yml" if ! /usr/local/bin/wp --quiet cron event run newsletter \ && ! /usr/local/bin/wp eval "wp_schedule_event(time() + 5*60, 'newsletter', 'newsletter');"; then echo "cron-newsletter ERROR." >&2 exit 1 fiMay 23, 2015 at 5:45 pm #16329
If someone is looking for a workaround.
#!/bin/bash # # Keep sending newsletters. Restore schedule if missing. export WP_CLI_CONFIG_PATH="/home/user/public_pm2/wp-cli.yml" if ! /usr/local/bin/wp --quiet cron event run newsletter \ && ! /usr/local/bin/wp eval "wp_schedule_event(time() + 5*60, 'newsletter', 'newsletter');"; then echo "cron-newsletter ERROR." >&2 exit 1 fiMay 23, 2015 at 5:46 pm #16330
My post vanishes.
- You must be logged in to reply to this topic.