Scheduled actions are a powerful plugin feature of WordPress that allows you to automate tasks. The action scheduler plugin will run these tasks in the background. These task can including sending emails, publishing posts, and updating products..
Why use Scheduled Actions?
The main advantage of using the Action Scheduler for your background tasks is its job queue. Having a job queue is better than a single cron with a large task.
Too many tasks can overload cron jobs. We use a job queue to run each task in small parts. A cron job within wordpress claims each job.
This process stops background tasks from slowing down your site or causing some other problem. The wp cron will run each Schedule Action quickly to stop a large complex task from using too much memory.
Popular WordPress plugins like WooCommerce, The Events Calendar, and WP Rocket use scheduled actions. These plugins use background tasks to keep your website’s information up-to-date. These tasks occur at specific times or on a schedule.
The WooCommerce Action Scheduler is the first exposure most uses have to Schedule Actions.
However, all of this activity creates large database tables and logs. These large queues of tasks will accumulate over time potentially slowing down your website. They also become hard to read and the old information has limited use for developers.
To efficiently clear scheduled action logs in WordPress, you can use SQL commands to delete them directly from your site’s database.
What will I learn in this How To Guide?
This guide will walk you through clearing scheduled action logs using two methods. Firstly, we will use the conventional method inside WP Admin.
The second approach will see the use of SQL commands inside the database to clear the action scheduler logs.
Both approaches aim to remove logs, which helps to keep your WordPress database lighter.
Table of contents
- Why use Scheduled Actions?
- What will I learn in this How To Guide?
- Video Tutorial: How to clear Scheduled Action Logs
- Method A: How to clear Scheduled Action Logs inside WP Admin
- Method B: How to Clear Scheduled Action Logs inside the Database
- Final Thoughts
- Frequently Asked Questions
Before proceeding, it is crucial to back up your WordPress database. This will ensure you can recover your data in case of any issues.
This method is also for users who are familiar with working directly with a database.
Video Tutorial: How to clear Scheduled Action Logs
Check out WordPress’s step-by-step video on How to Clear Scheduled Action logs in WordPress.
Method A: How to clear Scheduled Action Logs inside WP Admin
The first method of clearing out scheduled actions involves logging into the WP Admin Dashboard.
Step 1: Go to Scheduled Actions
Log into the WordPress Admin dashboard
- Go to the Tools menu item inside the WP Admin dashboard.
- Proceed to the Scheduled Actions sub-menu item under Tools.
Step 2: Clear Scheduled Action logs
- Select the type of Scheduled Action logs you would like to clear. This could either be the completed actions or failed actions.
- Bulk-select the logs by checking the first checkbox at the top-left side of the table.
- Select the Delete option on the drop-down and click Apply to clear the logs.
When deleting logs in bulk, ensure your host can handle deleting multiple logs simultaneously. Test the bulk delete process in a staging environment before using it in production to avoid breaking the site.
Method B: How to Clear Scheduled Action Logs inside the Database
This second method takes on the approach of executing the DELETE SQL commands directly in your database.
To remove logs using this method, follow these steps:
Step 1: Access Your WordPress Database Manager
You need access to the database manager to interact with your WordPress database.
For most hosting providers, their database manager is “phpMyAdmin.” It is often available through your hosting control panel. Follow these steps to access your database:
- Log in to your hosting account.
- Find and open the phpMyAdmin tool. This tool allows you to manage your MySQL database.
In this tutorial, we are using Cloudways hosting. We can launch the database manager by clicking the “Launch” button as shown below.
Step 2: Select Your WordPress Database
If your host uses phpMyAdmin, then you will see a list of databases on the left side of the screen. Locate and select your WordPress database from the list. Once selected, your database’s tables will appear in the right-hand pane.
With CloudWays, you will not need to cover this step since the database is pre-selected for you.
Step 3: Run SQL Commands to Clear Scheduled Action Logs
Now that you’ve selected your WordPress database, you can use SQL commands to clear the scheduled action logs. In this case, we’ll use two SQL commands:
Here’s how to execute these commands:
- In phpMyAdmin, navigate to the “SQL” tab at the top of the page. This is where you can run SQL queries.
For CloudWays, navigate to the SQL Command as shown below.
- Copy the first SQL command (
DELETE FROM wp_actionscheduler_actions WHERE status = 'complete';) and paste it into the SQL query box.
- Click the “Go” or “Execute” button to execute the command. This SQL query will delete completed scheduled actions from the
- After executing the first query, return to the SQL query box and paste the second SQL command (
DELETE FROM wp_actionscheduler_logs;).
- Click “Go” or “Execute” to run the second query. This SQL query will clear all the logs from the
Step 4: Verify the Deletion
Once you’ve executed both SQL commands, you should receive a message indicating that the queries were successful.
Visit your WordPress site and check the scheduled actions page to verify that the scheduled action logs have been deleted.
Using the SQL commands approach lets you directly interact with the database to delete multiple logs without crashing the site.
By default, the action scheduler log retention period is 30 days. Regularly clearing scheduled action logs before the retention period keeps your WordPress database running smoothly.
Remember to use the second method with caution. Back up your database before making any changes, and ensure you are comfortable working with SQL commands.
Frequently Asked Questions
Scheduled actions in WordPress refer to tasks or events that are set to occur at specific times or intervals.
These tasks can include publishing posts, sending emails, running backups, and performing various other automated actions.
The Action Scheduler plugin manages Schedule Actions. Automattic, the company behind WordPress.com and WooCommerce maintain the Action Scheduler Plugin.
Scheduled action logs are records of tasks or actions that WordPress has scheduled to occur at specific times or intervals. These include pending tasks, completed tasks and so on.
Clearing scheduled action logs is essential to maintain your WordPress database’s performance and efficiency.
Over time, these logs can accumulate and potentially slow down your website. Removing completed or unnecessary logs helps keep your site running smoothly.
Clearing scheduled action logs using SQL commands can be safe if done correctly.
However, it’s crucial to back up your WordPress database before making any changes. You should ensure that you are comfortable working with SQL commands. Mistakes in database operations can lead to data loss or site issues.
This is how long the action scheduler will store completed tasks before automatically deleting them. By default, the retention period is 30 days.