How to Safely Clean Unused Files and Set Up Cron Jobs in cPanel

⏲️ Estimated reading time: 3 min


Free Up Server Space Unused Files and Automate Maintenance in Minutes

Managing a WordPress website on cPanel? Over time, unused logs, backups, and temp files can clutter your server and slow things down. This post explains how to safely clean those unused files and automate ongoing maintenance using cron jobs for a faster, leaner site.


🧹 Why Cleaning Your Hosting Files Matters

Many website owners forget that shared hosting environments have limited storage. As your site grows, temporary files, old backups, and log files accumulate. If ignored, these can lead to:

  • Storage limit warnings
  • Slow website performance
  • Failed backups or script executions

Cleaning manually is possible, but automation saves time. That’s where cron jobs come in.


📁 What to Clean Safely in Your cPanel File Manager

Before deleting anything, always download a full backup.

1. Backup Archives

In folders like /home/youruser/ or /softaculous_backups, you’ll see files like:

backup-5.17.2025_08-04-45_helpzone.tar.gz
backup-5.31.2025_08-25-13_helpzone.tar.gz

Safe to delete if already downloaded locally.

2. Log Files

  • error_log
  • clear-cache.log
    These can grow to hundreds of MB over time.
    Safe to delete anytime. They regenerate automatically.

3. Temporary Files

Inside /tmp, you’ll find:

  • Session files
  • Stats data
  • Caching remnants
    Clean contents, not the folder itself.

4. Softaculous Backup Folder

If you used Softaculous to install WordPress, it stores automatic backups.
Delete backups here if you have your own copies.


⚠️ Files You Should Not Delete

File/FolderReason
public_htmlYour actual WordPress website
wp-config.phpCritical config file
optimize-db.shCustom database script
cron jobsCan stop site functions if removed

🛠️ Automating with Cron Jobs in cPanel

Cron jobs are time-based task schedulers. In WordPress hosting, they’re perfect for:

  • Clearing cache
  • Optimizing your database
  • Running scripts automatically
How to Create a Cron Job Unused Files

⏲️ How to Create a Cron Job

  1. Login to cPanel
  2. Go to Advanced > Cron Jobs
  3. Choose timing (e.g. once per week)
  4. Add your script’s command:

Example: Optimize WordPress Database

bash /home/YOUR_USER/optimize-db.sh

Example: Clear WordPress Cache via PHP

/usr/local/bin/php /home/YOUR_USER/public_html/clear-cache.php

✔️ Replace YOUR_USER with your actual hosting username.


🧮 Cron Timing Examples

Task FrequencyCron Expression
Daily at 2AM0 2 * * *
Weekly on Sunday0 0 * * 0
Every hour0 * * * *

You can also silence the output:

bash /path/to/script.sh >/dev/null 2>&1

🔁 Suggested Maintenance Schedule

TaskFrequencyMethod
Delete Old LogsWeeklyManual / Cron
Optimize DatabaseWeeklyCron Job
Clean /tmpMonthlyBash Script
Rotate BackupsMonthlyManual Review

🛡️ Bonus: Prevent Cron Job Overlap

Use this trick to avoid running the same cron job multiple times simultaneously:

if [ -f /tmp/cron.lock ]; then exit; fi
touch /tmp/cron.lock
# your script
rm /tmp/cron.lock

📘 Summary of Best Practices

  • Always keep a downloaded backup before deleting.
  • Use cron jobs to save time on repetitive cleanup tasks.
  • Don’t delete anything inside public_html unless you know exactly what it does.
  • Clean logs and temp files regularly to free up space.
  • Monitor cron job success by enabling email output or checking logs.

🔔 For more tutorials like this, consider subscribing to our blog.
📩 Do you have questions or suggestions? Leave a comment or contact us!

🏷️ Tags: cPanel, cron jobs, website cleanup, WordPress maintenance, optimize hosting, log files, web server, hosting tips, site speed, temp files
📢 Hashtags: #cPanel #CronJobs #WordPressSpeed #HostingTips #ServerCleanup #DatabaseOptimization #WebsiteMaintenance #WebHosting #LogFiles #TechTutorial

Report an issue (max 5 words):

Only logged-in users can submit reports.


Discover more from HelpZone

Subscribe to get the latest posts sent to your email.

Want to support us? Let friends in on the secret and share your favorite post!

Photo of author

Flo

How to Safely Clean Unused Files and Set Up Cron Jobs in cPanel

Published

Welcome to HelpZone.blog, your go-to hub for expert insights, practical tips, and in-depth guides across technology, lifestyle, business, entertainment, and more! Our team of passionate writers and industry experts is dedicated to bringing you the latest trends, how-to tutorials, and valuable advice to enhance your daily life. Whether you're exploring WordPress tricks, gaming insights, travel hacks, or investment strategies, HelpZone is here to empower you with knowledge. Stay informed, stay inspired because learning never stops! 🚀

👍 Like us on Facebook!

Closing in 10 seconds

Leave a Reply