Even though I disabled error reporting on the php settings, some scripts still make their own error_log files, some of them are eating all the space of my VPS.
I already know the errors, and I would like to force them to be unusable. The way I found was setting the permission 000 on the error_log files.
Now, how can I do it on every possible match on my server?
For example, I want to set permission 000 on every file named
error_log
.
Answer
find /var/log -name "error_log" -exec chmod 000 {} \;
would be the easiest, dirtiest way to do this. The clean one of course is to reconfigure your programs not to create those files in the first place.
By the way, if your programs are run as root, there’s no way you’ll stop them from writing the files with a permissions trick. In this case, you’ll need :
find /var/log -name "error_log" -exec chattr +i {} \;
which will set the immutable bit on your error_log
file, preventing all modifications. This requires root privileges.
If you decide to go for the clean way, here’s a little something that might help you :
grep "error_log" /etc -R 2> /dev/null
This will find all occurences of “error_log” in your configuration files (assuming they’re somewhere in /etc
). Edit your configurations accordingly, and don’t hesitate to narrow the search down to some directories only, or to another filename (use the absolute path to error_log
perhaps?).
Attribution
Source : Link , Question Author : viniciusmunich , Answer Author : John WH Smith