Hello, Today I check few of my websites folder under my web server I found that most of the folders contains the file "error_log" at some folders it is in smaller size but in others its around 600-900 MB in size per file. My question is 1. Whether its wise to stop creation of that file by Apache? If yes then how to stop it? 2. Second question is can we stop it for only few websites? 3. And is that safe to delete error_log file? If yes how to search that file in SSH and how to delete it using one command as it would be really hard to delete one by one from each folder. EDIT about question 3: I found this command: cd /home find . -name error_log find . -name error_log -exe rm -f {} \; find . -name error_log the above commands will first find all files and list them, the next one will find all files and remove them, the last will confirm that all the error log files have been deleted. Code (markup): But the command below dont work: find . -name error_log -exe rm -f {} \; Code (markup): Please help me with this. Thank you! -Regards.
Hi there, Pretty sure you are missing the "c" off the end, should look something like so: find . -name error_log -exec rm -f {} \; Code (markup): Alternatively, I would suggest you do not remove the file completely, as is is useful for tracking down errors. I usually just clear them out, by doing something along these lines: echo > /home/username/public_html/error_log Code (markup): Chris
Hi, you can clear the error logs of apache,mysql,exim by using the below steps >> First keep last 1000 logs to a file tail -1000 /var/log/messages /var/log/messages.bbkp >> clear full logs in messages > /var/log/messages >> tail -1000 /var/log/messages.bkp > /var/log/messages done
Hi Divvy, I can see that you have 3 questions. 1. Whether its wise to stop creation of that file by Apache? If yes then how to stop it? The file error_log is one of the most important files of apache and removing/stopping it is not recommended. This file helps us in trouble shooting issues related with apache. 2. Second question is can we stop it for only few websites? We can assign a specific error_log file for each domain name in httpd.conf so that we can easily find the errors related to that domain. 3. And is that safe to delete error_log file? If yes how to search that file in SSH and how to delete it using one command as it would be really hard to delete one by one from each folder. The location of the error_log file depends on which control panel is installed. We can also use the command "locate error_log" to find the location. You can clear the file by giving this command "> error_log".
Hi, Kindly move the logs to Some other Destination For Ex: mv access_log access_log.old Which will resolve this issue
I think this one is most lightweight command of all mentioned. I found "rm -rf" takes ages to delete alot of files in directory etc. But find command mentioned by Pathan works really way faster. one can also set only delete files if size is larger than 500kb for example: find /home -type f -name error_log -size +500k -print "-print" shows what files match your criteria "-delete" deletes without confirmation
To clear without removing: for file in /home/*/public_html/error_log; do echo > $file; done; you can also crawl into deeper directories by adding some "*"'s for file in /home/*/public_html/*/error_log; do echo > $file; done; for example
I like that I even don't need to ask a question) Just come here and find everything you need. Thanks for your valuable answers!