PDA

View Full Version : Regularly delete files using Cron, save disk space on Your hosting



Fli
03-21-2013, 05:11 PM
Hi, You have webhosting on cpanel or similar? Your hosting can be set the way to save various visitor statistics data or your error_log file might be growing to Megabytes, even gygabytes of data.

Here is the command im using to run twice a day on my hosting accounts:

rm -rf /home/yourusername/mail/new/*;rm -rf /home/yourusername/public_html/error_log;rm -rf /home/yourusername/public_html/*/error_log;rm -rf /home/yourusername/public_html/*/*/error_log;rm -rf /home/yourusername/tmp/analog;rm -rf /home/yourusername/tmp/awstats;rm -rf /home/yourusername/tmp/webalizer;rm -rf /home/yourusername/tmp/webalizerftp;

This command is to be added in the Cronjob section of your hosting. Add it only if you know what this command exactly do. The files deleted by this command might not be able to recover.

What above cronjob command do?

- It deletes system emails stored in mail/new
- It deletes errror_log files on your account, 2 levels deep from public_html
- it deletes statistics data of webalizer, webalizerftp, awstats and analog (by deleting its folders).

Similar topic: How to setup cronjob (http://internetlifeforum.com/general-webhosting-issues/31-how-setup-cronjob/) to visit some script/url