Support

Home Forums Event Espresso Premium cron directives are getting removed

cron directives are getting removed

Posted: January 13, 2021 at 12:13 pm


ICLE

January 13, 2021 at 12:13 pm

If we are to continue troubleshooting messages we can do that in a new thread as the other is already long and repurposed from an issue with FirstData.

However, I once again logged into the site and checked the cron jobs.

AHEE__EE_Messages_Scheduler__generation
AHEE__EE_Messages_Scheduler__sending

Were missing again but

AHEE__EE_Messages_Scheduler__cleanup

Was still active.


ICLE

January 13, 2021 at 12:45 pm

Why or how can that happen? No one is working on the site.


Tony

  • Support Staff

January 13, 2021 at 4:07 pm

Unfortunately, I can’t tell you why those cron’s are being removed, they are actually managed by WordPress itself and not Event Espresso.

EE activates and calls wp_schedule_event({time}, {frequency}, {hook_name}) to add the scheduled tasks, WordPress than take over and ‘should’ rescheduled the task as it runs, apparently that is failing on your site.

In English, it’s like me saying to you ‘Drink water every 5 minutes until I tell you otherwise’ and then leaving you to manage that yourself. If you stop drinking water I don’t know until we next have a catchup. Same idea here, we tell WordPress to run that cron every 5 mins and somewhere that event is lost and not rescheduled, where/why that happens I can’t tell you as it’s not under EE’s control.

The AHEE__EE_Messages_Scheduler__cleanup runs once daily (think of it as the catchup mentioned above) and within the callback function for that hook we confirm that the other 2 are scheduled, if not we reschedule them. We basically do this as a precaution to try and make sure the message crons are always working.


Tony

  • Support Staff

January 13, 2021 at 4:08 pm

I did log into the site and checked the crons, they are currently showing in the list, although AHEE__EE_Messages_Scheduler__cleanup ran a couple of hours ago now so they may have been missing earlier and once again re-added when that ran.

I’ll check this again when I log in in the morning to see if they are still active.


ICLE

January 14, 2021 at 8:21 am

We found some waiting for generating at 10AM and manually sent them.


Tony

  • Support Staff

January 14, 2021 at 9:31 am

Yeah so your site is randomly dropping the message crons, they aren’t listed now, but will be again in roughly 3 hours when AHEE__EE_Messages_Scheduler__cleanup runs again.

Any errors in the servers error logs overnight? Memory exhausted errors or any fatal errors, do not just look for errors related to Event Espresso as the schedules tasks are not managed by EE.

One thing you can try is increasing the interval time when those crons run using something like this:

https://gist.github.com/Pebblo/ee50c033271de885cd907d189532a513

There are reports elsewhere of 1-minute cron events randomly disappearing:

https://wordpress.stackexchange.com/questions/158303/scheduled-events-disappear-from-events-queue

5 minutes (which we use) is usually fine (although there are some reports of those disappearing as well) but bump it up to 10 and see if it helps.


ICLE

January 14, 2021 at 11:08 am

OK. I will look into the interval times and watch the results and report back.

Here is a response from my server manager:
“We run backups everyday. Midnight and 4 am. One is for Bluehost’s Codeguard Basic and one sent offsite to Google Drive. We do not run any Cron jobs from the server.”


ICLE

January 14, 2021 at 3:02 pm

I two questions:
1) where should this code go? into functions.php?
2) is the following for 1 minute, 100 seconds, etc?
add_filter(‘cron_schedules’, ‘tw_ee_increase_message_cron_interval’, 100);


Tony

  • Support Staff

January 14, 2021 at 3:08 pm

1) where should this code go? into functions.php?

functions.php should work but we usually recommend using a custom functions plugin, you already have multiple instances of those and you don’t need to create another just add the code onto the end of one to those plugins.

2) is the following for 1 minute, 100 seconds, etc?
add_filter(‘cron_schedules’, ‘tw_ee_increase_message_cron_interval’, 100);

Neither, that’s a ‘hook’ call back.

It’s saying “hook into ‘cron_schedules’ and run ‘tw_ee_increase_message_cron_interval’ to do its thing at priority 100”

The code changing the timing of the cron schedule is THIS LINE, setting the interval to 600 seconds (10 Minutes).

For more info on hooks, see:

https://www.smashingmagazine.com/2011/10/definitive-guide-wordpress-hooks/


ICLE

January 22, 2021 at 1:25 pm

Do you happen to know the times of day the catchup runs?
What is the process to replace the cron definitions that get removed?


Tony

  • Support Staff

January 23, 2021 at 4:40 pm

Do you happen to know the times of day the catchup runs?

It runs once daily but due to the way WP_CRON works it’s not exact (because it relies on users hitting the site).

If you go to Dashboard -> Tools -> Cron Events

Search for ‘AHEE__EE_Messages_Scheduler__cleanup’ and you’ll see when the next runtime is scheduled.

What is the process to replace the cron definitions that get removed?

If AHEE__EE_Messages_Scheduler__cleanup is available above, click run. If the other 2 are not in the list, running it will add them.

If AHEE__EE_Messages_Scheduler__cleanup is not in the list it needs to be added manually and then run.

Click Add new at the top.

Add a standard cron event, hook name is AHEE__EE_Messages_Scheduler__cleanup repeat once daily and add. Then run it.


ICLE

January 29, 2021 at 11:52 am

I just noticed this message at the top of the Cron Events screen:
The ALTERNATE_WP_CRON is set to true.

Would that have any impact?


Tony

  • Support Staff

January 29, 2021 at 12:14 pm

No, I told you to enable alternate wp cron in your other thread here:

https://eventespresso.com/topic/how-can-we-find-out-if-firstdata-is-timing-out/#post-319551

The reason for doing so is because loopback requests don’t work on your site and therefor ‘normal’ WP_CRON doesn’t work.


ICLE

January 29, 2021 at 12:17 pm

Could I set
AHEE__EE_Messages_Scheduler__cleanup
to run once an hour to help things along?


Tony

  • Support Staff

February 1, 2021 at 9:02 am

You could try it, running the cleanup job more frequently should not cause any issues that I can think of although I do recommend you monitor the site for a little once you’ve changed it just to be safe.


ICLE

February 4, 2021 at 9:25 am

Is there a possibility of a message not being sent within 40 minutes with the above scenario of the cleanup cron only running once per hour? When the cleanup cron runs, might it skip any pending messages or transaction detail sends?


Tony

  • Support Staff

February 4, 2021 at 9:42 am

Is there a possibility of a message not being sent within 40 minutes with the above scenario of the cleanup cron only running once per hour?

If the cleanup is scheduled for every hour on the hour and the above 2 generating and sending crons are ‘lost’ at say 2 minutes past, then the crons wont be added back into the system until the next cleanup is ran, which will 1 hour+ (the plus is because hit relies on a hit on your site to trigger it).

Meaning it is possible to take over 1 hour and 10 minutes (1 hour for cleanup to trigger above, 5 minutes per step for the message queue) plus the time i takes for a user to hit the site after the job has been scheduled.

When the cleanup cron runs, might it skip any pending messages or transaction detail sends?

I can’t think of a reason it would skip them. The cleanup job is just making sure the crons are in place, the cron running would be running as normal. If it w is missing it’s not processing any new messages, when its added again, it will run and pick up where it left off last time it ran.

The support post ‘cron directives are getting removed’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso