• Resolved pcoweb

    (@pcoweb)


    I’m having issues with the cron job. I can see the cron pta_sus_cron_job in the cron events hourly and I run a ‘real cron’ to trigger wp-cron.php every 15 min. I can see the cron_pta_sus_cron being renewed in the cron queue, but the page ‘Sign up Sheets>Cron Functions’ is not showing changes to the ‘Last Reminder Check’. Is there a command line that I can use to check something? I am also comfortable to look in tables if that is helpful. I have access to WP-cli.

    More details: I use ‘WP Mail SMTP’ and the confirmation emails have been going out fine. I checked ‘Settings>Email Settings’, and find ‘Disable Reminder Emails’ and ‘Disable ALL emails’ are unchecked. I tried toggling them on, saving then toggling off and resaving.

    I recently noticed a problem with the action scheduler that an action_scheduler/migration_hook had failed (over a year ago!) and so I installed the ‘Action Scheduler’ plugin and I was able to run that hook. But it had been a long time since that migration_hook had failed and I had never noticed the issue. After fixing that, I did click the button ‘Send Reminders’ and I did get an admin report that the reminders were sent and the ‘Last Reminder Check’ did update to the time when I sent them manually.

    Another side note: The setting “Automatically clear expired signups?” is checked for ‘Yes’, but apparently they were not being deleted because on the ‘Sign up Sheets>Cron Functions’ tab when I clicked the button to ‘Clear Expired Signups’ about 450 items were purged. Also, I run the Sign up sheets ‘Customizer’ and ‘Custom Fields’ plugins.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author DBAR Productions

    (@dbar-productions)

    This is a tough one for me to help you without access to your site/server. I haven’t changed anything with the CRON functions for a very long time, and I have not had any reports from others about similar issues, so I don’t believe it’s a code issue. This is most likely something specific to your server and install.

    Have you checked with anyone to see if the reminders are actually getting sent or not? Or create a test event and sign up yourself to see if you get any reminders yourself?

    My guess is that somehow the way you have set things up, the CRON job/function is not getting triggered properly, especially if in addition to no reminders being sent you also are not getting expired signups cleared. Reminder emails, Reschedule emails, and the purging of expired signups, are all triggered off of one function that should get called anytime that CRON hook is triggered.

    The first place I would check is your server’s PHP error log to see if something is throwing errors when the WordPress CRON function is triggered. It’s possible some other plugin’s CRON functions are causing a fatal error, thus preventing further execution of any other CRON functions from other plugins. If you don’t see anything there, you may want to temporarily configure the WordPress debug function and set it to debug to a log file (NOT to the screen), and see if you see any errors or warnings in there when the CRON function gets triggered.

    Also, the Action Scheduler is not part of WordPress core, and is usually installed by other plugins (such as WooCommerce). Action Scheduler is set up in a way that it should use the newest version if there are multiple versions of it installed (via different plugins). Unless you absolutely need it installed as a stand alone plugin, I would uninstall that plugin and let WooCommerce or the other plugins keep it updated. Sometimes a job fails due to errors in the code for the job or because a function took too much time and it timed out before it could finish. That doesn’t mean that there is something wrong with Action Scheduler and that you should install it separately. Note that I do NOT use the Action Scheduler in any of my plugins. But, if something that uses Action Scheduler is causing fatal errors or timeout errors, that could possibly affect the CRON jobs since I believe it works off the same CRON hooks.

    The CRON hook for my plugin is set up during activation. So, you could try to deactivate the plugin and then reactivate it, and that should check if the hook is registered, and, if not, it will set it up again. You say that you see it in the CRON hook list, but it’s worth a try to see if that helps at all. As far as database entries, things like the last reminders sent data are stored in the default wordpress options table. Just search for entries that start with ‘pta_sus_’ for the option key, and you’ll find a few. The reminders sent option is only updated when any reminders are sent, and they are only counted as being sent if the email function returns a true value. If you have replaced the WordPress mail function with a SMTP plugin, then that plugin also needs to return a true value when an email is sent, or else my plugin will think it wasn’t sent and it won’t update the sent count. I don’t think that’s your issue, though.

    Doing some quick searching, I see that in the past some people have had issues with CRON jobs from various plugins not working correctly when they disable the WordPress CRON and then use a “real cron’ server setup to trigger wp-cron.php. Even though everything looks fine when you see the scheduled CRON jobs, it seems that calling wp-cron.php directly that way may not ensure that all plugins are initialized properly in time for their CRON hooks to be registered and to fire properly. I would suggest that you re-enable the WordPress CRON function and remove the server side real CRON call to wp-cron, and see if that fixes that issue. If your site gets enough traffic (even if it’s search engines or bots crawling your site), the CRON jobs will get checked every time WordPress is loaded, so there would be no need for a “real cron” job if your site is getting hits at least once every 15 minutes.

    Thread Starter pcoweb

    (@pcoweb)

    thanks for the quick thorough reply.

    I had previously deactivated and reactivated the sign-ups plug in. I forgot to mention that.

    I have been assuming that the ‘Last reminder check’ time should update even if no emails are sent. That is not changing when the cron runs.

    I had time to try only a few things tonight. I turned on debugging and when looking at debug.log, I do not get errors when I run the pta_sus_cron_job from the web interface of the cron queue, but it does not result in reminders or an update of the last reminder check. However, when I clicked the button on the cron functions page, the reminders were sent and there were also no errors logged.

    I am a volunteer, so it may take me a couple of weeks to look into this farther. I will install the Query Monitor so that I can see more what is happening from the two different methods of triggering, and I can also look in the options table as you suggest. I will also turn off the external cron call to see if that is the cause.

    I did uninstall the action scheduler. The core of the scheduler is used by ‘WP Mail SMTP’ without the plugin, but since I had the dangling ‘migrate’ error, I installed that to fix it. There troubleshooting suggest to remove after the issue is fixed, and I did do that now, especially since your plugin is not using it.

    Plugin Author DBAR Productions

    (@dbar-productions)

    Yes, the last reminder check should update any time that function is run.

    If it works when you run it manually, then it’s something with the CRON function not triggering the corresponding action in my plugin. The CRON action in my plugin calls the same functions that are used when you manually trigger the functions (reminders, deleting expired signups, reschedule emails).

    So, from your tests, we know that there are no errors and the function that sends the reminders is working when you trigger it manually (also without errors). That just leaves an issue with the “real cron” call of wp-cron.php somehow not triggering the action in my plugin that runs the same functions.

    If you keep testing on your end, I will see if I can set up a test site on a real server (not my local dev environment) where I can use a real CRON function to trigger wp-cron.php, and see if I can replicate the issue. If so, I can try to figure out a way to make sure my action gets registered and triggered when wp-cron.php is called that way. That could take me some time also.

    Thread Starter pcoweb

    (@pcoweb)

    The main issue was that the hosting provider was running a script to trigger cron, but something was not configured properly. After they turned that off I am running my own cron that runs ‘/usr/bin/wp cron event run –due-now’. Your plugin is showing updated times on the ‘Last Reminder Check’.

    After I started investigating, only three plugins were getting triggered! I will keep you informed, but it appears that it was a problem with the hosting service trigger script.

    Your plugin is working fine when triggered with a real cron that runs ‘/usr/bin/wp cron event run –due-now’ and I am logging the output and error (none so far) to confirm which hooks are executed.

    Thanks again for the quick detailed reply and suggestions for troubleshooting.

    I plan to return in a week to mark this as resolved. I want to run my cron for a while before assuming everything is fixed.

    Thread Starter pcoweb

    (@pcoweb)

    Just confirming that everything is good with sign-up sheets. The volunteer sheet cron has been running fine since the hosting provider removed their cron and I am running a real cron to trigger the WP cron.

    Plugin Author DBAR Productions

    (@dbar-productions)

    Thanks for letting me know. Glad you got it working!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.