One of the most sought features on websites is the ability to allow automation through scheduled tasks. This fit can be achieved through the use of server Task Schedulers or Cron, but with many hosting providers offering shared hosting, task schedulers may be disabled, enter WP-Cron. WP-Cron allows tasks to be scheduled for future dates or at a given time interval.
WP-Cron jobs get triggered on page load which can be problematic as some sites have little traffic which means tasks may not be scheduled at the time that they need to. There is also an issue with managing scheduled events as WP-Cron does not come with an interface for this.
These issues can be resolved with the use of the Action Scheduler plugin. This plugin uses the WP-Cron functionality and has been designed to handle many of the shortcomings of WP-Cron. It comes pre-installed in woocommerce or can be installed as a stand-alone plugin
What does Action Scheduler do?
Action Scheduler allows you to schedule particular tasks that you want to run in WordPress over and over again. You’re able to call this API every after a pre-determined time and it will be running in the background.
WooCommerce uses Action Scheduler to run database updates and do a number of things in the background. We can leverage this Action Scheduler to also do what we want to do.
For example, if you’re developing a tracking app and you’re calling data from a centralized server and the information will be coming in.
The Challenge with Action Scheduler
Action Scheduler uses a custom WordPress table to store scheduled actions at different stages. Over time as the schedules keep running, the table gets filled with redundant data, while the plugins overs cleanups every 30days, this may be an issue in scenarios where multiple actions are running at a time.
Cleanup Actions Scheduler allows you to adjust your database cleanup frequency from the default 30days to any period of your choosing. It also allows for immediate deletion of scheduled actions at any given status ie Pending, Completed, Failed, In-progress, and Canceled.
The Cleanup Actions Scheduler Plugin
On initial activation of the plugin, you will need to add your license to activate it. Your license will be sent to your provided email upon purchase of the plugin. You will then be redirected to the plugin setting page from which you may adjust your action scheduler cleanup frequency.
Scheduler Cleanup Frequency can be set to happen in seconds, hours or days.
Immediate Action Deletion
Cleanup Action scheduler allows you to bulk delete scheduled actions by state. This can be done by clicking the bin action next to the scheduled groups as shown in the image below.
We hope that this plugin will give you the flexibility and control needed in cleanup scheduled events while working wih the Action Scheduler Plugin.
If you have any questions feel free to contact us.