If you have a large number of accounts on your server, you may also be wasting a lot of space with the error_log files in each account. Some can get very large – and while you want to keep an eye on what the server is complaining about, once you read through them, you can wipe them out with one swift command.
Let’s first see how much space they’re all using!
SSH to the server in question and type this command to list out all of the account error_logs along with their size:
1 |
find /home -type f -name error_log -exec du -sh {} \; |
On the left, you’ll see the size, on the right you’ll see the path.
1 2 3 |
4.0K /home/user1/public_html/error_log 20M /home/user2/public_html/error_log 420M /home/user3/public_html/error_log |
I’d take a peek at what some of the bigger ones are complaining about to see if you can fix the issues. Once you’re finished up, we’ll delete them all (and apache will re-create them if it wants/needs to).
Ok, so we’re assuming you’ve read through and gained any knowledge of what the server was complaining about (and remedied any issues!).
Let’s delete those suckers! Typing the following command will delete all instances of ‘error_log’ beneath the /home/ directory.
1 |
find /home -type f -name error_log -delete |
Now, you can follow up with the previous command and you should be met with nothing except your shell prompt.
I’d suggest that you schedule a cron job to clear them out weekly.. like, let’s clear them out every friday night:
1 |
0 22 * * fri /bin/find /home -type f -name error_log -delete |
Thanks for reading! Share this w/ your friends!