How Xeroom Handles Cron Jobs

How Xeroom Runs Batch Jobs Using Cron

Xeroom handles the order Bulk Send and inventory synch processes by spawning a cron job hook which is handed over to WP to execute.  WP will execute it whether by the default wp-cron,  from cpanel or a third party service.  WP-cron is sometimes turned off by hosts and/or replaced by a scheduled running of all requests.  If cron is set to run too frequently ie mover than once every 5 minutes and the user repeatedly triggers the request due to seeing it not run then there can be a big load placed on the server due to one job not completing before the others are started which can lead to the server going slower and slower and freezing for a while.

So when you do the Bulk Send action you should see that job kicked off and be processed, it won’t always be instant as it is due to the cron schedule and what other processes are running.  The bulk orders setting should be set to 4.  Here is a video to explain it. https://d.pr/v/yS4hEd  It should run after a minute or two and we have added a cancel button in case it remains suspended.

The cronjob scheduler plugin if used will tell you to disable the default wp-cron processer by putting this statement in wp-config and then to create a unix job in cpanel for your server  define(‘DISABLE_WP_CRON’, true);

However our experience is that some hosts will override or control this.   The WP crontrol plugin will enable you to see what is going on with your wp-cron system and show you all the events and schedules.  If it is not running then you need to speak to your host to determine why. You can also check the cron logs on your server https://cronitor.io/cron-reference/where-are-cron-logs-stored Note that cron is used by other parts of WordPress and detailed in the articles below.

1. Install the WP Crontrol plugin and update the attached file in your Xeroom plugin directory.
2. Set the batch send number to 4 in Xeroom settings
3. Run a Batch send and check if the cron job is spawned – If other cron jobs are running and no Xeroom job is spawned then there is something preventing it.  Try a few times and if it never appears let us know.  If it does appear then the problem is with the cron not running.
4. Check to see if WP-cron is disabled or not and if it is how cron jobs are run on your server.

Further reading/info on WordPress Cron Jobs

2. From the WordPress handbook https://developer.wordpress.org/plugins/cron/
 
What is WP-Cron?
WP-Cron is how WordPress handles scheduling time-based tasks in WordPress. Several WordPress core features, such as checking for updates and publishing scheduled post, utilize WP-Cron. The “Cron” part of the name comes from the cron time-based task scheduling system that is available on UNIX systems.

WP-Cron works by checking, on every page load, a list of scheduled tasks to see what needs to be run. Any tasks due to run will be called during that page load. :WP-Cron does not run constantly as the system cron does; it is only triggered on page load. Scheduling errors could occur if you schedule a task for 2:00PM and no page loads occur until 5:00PM.

 

Why use WP-Cron?
· WordPress core and many plugins need a scheduling system to perform time-based tasks. However, many hosting services are shared and do not provide access to the system scheduler.
· Using the WordPress API is a simpler method for setting scheduled tasks than going outside of WordPress to the system scheduler.
· With the system scheduler, if the time passes and the task did not run, it will not be re-attempted. With WP-Cron, all scheduled tasks are put into a queue and will run at the next opportunity (meaning the next page load). So while you can’t be 100% sure when your task will run, you can be 100% sure that it will run eventually.