I'm new at hosting my VPS on a CentOS linux server.
The following log files grow quite rapidly and I would like to have them deleted every 24 hours:
/home/httpd/tanguay.info/stats/tanguay.info-custom_log
/home/httpd/tanguay.info/stats/tanguay.info-error_log
/home/admin/__processed_stats/*
What would be the steps for me to create a cron job that deletes all of these files every night at midnight?
It is not recommended to immediately purge logfiles as they may be needed later for debugging, statistics or tracing an intrusion. While log shipping offsite may be overkill in a single VPS scenario, there are better approaches than simply deleting those.
I suggest you look into logrotate or cronolog (Probably available as package on CentOS). With these packages you can set up rules how to process logfiles on a (usually) daily basis, like: Keep a week worth of logs, but compress all of them except today's.
You can also reduce the information being sent to the logs. You can set it to only log errors instead of information, warnings, and errors. Just a suggestion. If you want to delete the logs, make sure they are still not in use. Rotate your log files like everyone else has suggested. They usually get compressed and deleted after a period of time.
Logrotate is the best method. In any case, you need to send the HUP signal to httpd afterwards, otherwise the filehandle for your log gets left open and your filesystem will fill up but won't be reflected in the sizes of the files.
To empty the files every day at 1AM you may use :
But the good way is to use logrotate
You may also want to take a look to : log rotation tool that keeps only a specified amount of logs and discards everything else and Apache access log rotation