⏲️ Estimated reading time: 3 min
✅ How to Safely Clean Unused Files and Set Up Cron Jobs in cPanel
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/Folder | Reason |
---|---|
public_html | Your actual WordPress website |
wp-config.php | Critical config file |
optimize-db.sh | Custom database script |
cron jobs | Can 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
- Login to cPanel
- Go to Advanced > Cron Jobs
- Choose timing (e.g. once per week)
- 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 Frequency | Cron Expression |
---|---|
Daily at 2AM | 0 2 * * * |
Weekly on Sunday | 0 0 * * 0 |
Every hour | 0 * * * * |
You can also silence the output:
bash /path/to/script.sh >/dev/null 2>&1
🔁 Suggested Maintenance Schedule
Task | Frequency | Method |
---|---|---|
Delete Old Logs | Weekly | Manual / Cron |
Optimize Database | Weekly | Cron Job |
Clean /tmp | Monthly | Bash Script |
Rotate Backups | Monthly | Manual 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
Only logged-in users can submit reports.
Discover more from HelpZone
Subscribe to get the latest posts sent to your email.