Clear LiteSpeed Cache Automatically

The Guardian of the Cache: Automating Your Website’s LiteSpeed Cache Clearing

Boost your site’s speed with TVCNet. From LiteSpeed cache automation to cPanel support, we provide the best website hosting for high-performance results.

When your LiteSpeed Cache grows larger than 1 Gigabyte, it can shift from a performance booster to a storage burden. To keep your server lean, we use a “Cron Job”—a digital guardian that wakes up at midnight to tidy the files.

The Step-by-Step Method

1. Access the Control Center. Log in to your cPanel and navigate to the Advanced section. Click on Cron Jobs.

2. Set the Midnight Ritual. Scroll down to Add New Cron Job. In the Common Settings dropdown, select “Once Per Day” (or manually set Minute: 0 and Hour: 0). This ensures the cleanup happens while your visitors are asleep.

3. Cast the Incantation (The Command). In the Command text field, paste the script below. We have updated it specifically for your account:

LARGE_LSDIR="$(du --threshold=1G -sh /home/yourusername/lscache/ | cut -f2-)"; for ls_path in $LARGE_LSDIR; do echo "$(date): Clean up $ls_path"; find $ls_path -type f -mmin +1440 -exec rm -f {} \;; done >> /home/mollyspo/cron_log.txt 2>&1


What this does:
It checks whether /home/yourusername/lscache/ exceeds 1 GB. If so, it deletes files older than 1,440 minutes (24 hours) to free space and logs the details in the cron_log file.


4. Seal the Automation.
Click the Add New Cron Job button. Your automation is now active!

5. Test Me. Set the cron for one minute and change the text from “threshold=1G" to something like "threshold=200" where 200 equals 200 MB.


Why This Matters

By automating this process, you ensure that your website stays fast without ever having to manually clear a cache folder again. It’s the “set it and forget it” way to maintain peak performance for your WordPress website.

Need Help?

Send the log snippet (time + unique_id) and the affected URL.
We’ll fix the block, clean safely, and tune things so it stays fixed.
Get help from TVCNet.com

#WordPress #cronjobs #space #SmallBusiness #cpanel

Similar Posts

Leave a Reply