Been a while since I’ve posted any snippets, but this one was rather handy. We had shortage of File space on a production server. An old PHP Set-up we had running started to produce some heavy error logs. I didn’t want to have to find how much space this was grossing, so this handy lil’ command line lists & tells you just that.
/bin/find / -type f -name error_log | xargs du -h --total
Which will produce you a neat little list:
4.0K /home/site1/public_html/error_log 4.0K /home/site2/public_html/example/error_log 9.6M /home/site2/public_html/homepage/error_log 600K /home/site3/public_html/common/error_log 12K /home/site2/public_html/scripts/user/error_log 30.2 Total
If you wish then to delete them, replace
| xargs du -h --total with the
-delete flag for find:
/bin/find / -type f -name error_log -delete