How to clear scheduled actions log in WordPress
Home / Blog / Tutorials / How To Clear Scheduled Action Logs in WordPress

How To Clear Scheduled Action Logs in WordPress

Scheduled actions are a powerful plugin feature of WordPress that allows you to automate tasks. The action scheduler plugin will run these tasks or actions 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. A single cron can double up work or cause an endless loop. This can overload cron jobs and potentially crash your whole website or server.

Action Scheduler processes a job queue to run each task in small parts. Each task is logged as a pending action. Every 1 to 5 minutes your server cron will come along and process actions placed in the queue for background processing.

This process stops background tasks from slowing down your site or causing the same action from being processed many times. The wp cron will run each Scheduled Action once. This will stop a large complex task from using too much memory.

Background processing large queues with the Action Scheduler is a common feature of WordPress plugins. These plugins can run complex actions quickly and avoid a website slow down. The only downside is Action Scheduler can make large logs in your database.

Why do Plugins use the Action Scheduler?

The WooCommerce Action Scheduler is the first exposure most uses have to Scheduled Actions.

Popular WordPress plugins like WooCommerce, The Events Calendar, and WP Rocket use scheduled actions as a job queue for background tasks. These background tasks keep your website’s information up-to-date, can send reports or clear cache information. These tasks occur at specific times or on a schedule depending on each plugins use case.

All of this plugin activity creates large Action Scheduler queues in your database. These large queues of tasks will accumulate over time potentially slowing down your website. The log can become hard to read and the log entries have limited use for developers.

By default the Action Scheduler has a retention period of 30 days for these logs. It is possible to add a filter to Action Scheduler to change this retention period. Alternatively you can using a premium plugin to adjust log retention.

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.

Action scheduler cleaner plugin

Clean your log the easy way

Use the Action Schedule Cleaner.

Instant log clear tool. Make your site faster and easier to maintain.

Save 50% with code BLOG50 on checkout.

Note

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

  1. Go to the Tools menu item inside the WP Admin dashboard.
  2. Proceed to the Scheduled Actions sub-menu item under Tools.
How to go scheduled actions in WP Admin
How to go to Scheduled actions in WP Admin

Step 2: Clear Scheduled Action logs

  1. Select the type of Scheduled Action logs you would like to clear. This could either be the completed actions or failed actions.
  2. Bulk-select the logs by checking the first checkbox at the top-left side of the table.
  3. Select the Delete option on the drop-down and click Apply to clear the logs.
How to delete scheduled action logs inside the WP Admin
How to delete scheduled action logs inside the WP Admin

Caution

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:

  1. Log in to your hosting account.
  2. 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.

Launch Database manager inside Cloudways
Launch Database manager inside Cloudways

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:

  1. 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.
SQL command tab inside Cloudways DB manager
SQL command tab inside Cloudways DB manager
  1. Copy the first SQL command (DELETE FROM wp_actionscheduler_actions WHERE status = 'complete';) and paste it into the SQL query box.
  2. Click the “Go” or “Execute” button to execute the command. This SQL query will delete completed scheduled actions from the wp_actionscheduler_actions table.
Delete completed scheduled actions.
Delete completed scheduled actions.
  1. After executing the first query, return to the SQL query box and paste the second SQL command (DELETE FROM wp_actionscheduler_logs;).
  2. Click “Go” or “Execute” to run the second query. This SQL query will clear all the logs from the wp_actionscheduler_logs table.
Delete action scheduler logs SQL command.
Delete action scheduler logs SQL command.

Step 4: Verify the Deletion

Once you’ve executed both SQL commands, you should receive a message indicating that the queries were successful.

Notification confirming completed actions deletion.
Notification confirming completed actions deletion.

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.

Final Thoughts

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

What are scheduled actions in WordPress?

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.

What are action scheduler logs in WordPress?

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.

Why should I clear scheduled action logs?

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.

Is it safe to clear scheduled action logs using SQL commands?

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.

What is the action scheduler retention period?

This is how long the action scheduler will store completed tasks before automatically deleting them. By default, the retention period is 30 days.

Can I remove the Action Scheduler from WordPress?

If you are using WooCommerce or a plugin that uses Action Scheduler you are forced to utilise it. This is a good thing. The Action Scheduler is an excellent scalable traceable job queue.

Action scheduler cleaner plugin

Clean your log the easy way

Use the Action Schedule Cleaner.

Instant log clear tool. Make your site faster and easier to maintain.

Save 50% with code BLOG50 on checkout.

Similar Posts