I have a file /var/logs/apache2/error.log
. And every time I boot, Its file permission is changed to default (unwritable) by the system. So, i have to run chmod
command every time i boot-up. How to change it's file permission permanently.
I have a file /var/logs/apache2/error.log
. And every time I boot, Its file permission is changed to default (unwritable) by the system. So, i have to run chmod
command every time i boot-up. How to change it's file permission permanently.
Log files are usually created by logrotate. The apache logfiles definition is stored on /etc/logrotate.d/apache2
The file looks like this in one of my servers:
If you look at the create option, the values after the keyword are the permissions, user and group. Just edit your file and change this values.
I'm guessing
anacron
is runninglogrotate
at boot time.If so, try editing the configuration file
/etc/logrotate.d/apache2
, and changeto whatever you prefer, e.g.
But other than the
apache2
service, what else needs to write to this file?If this is on a server, it's probably a bad idea to make the file world writable. For example, if somebody breaks in to your system, they can remove the log entries that would help you find the problem.
If you want read access, it might be better to add yourself to the
adm
group, e.g.This would also help if you really do need write access, e.g.
would be sufficient.
As per the discussion in comments, for the purpose the OP is trying to achieve (looking at a simple subset of logs for a specific purpose), this may be an appropriate alternative solution:
Tail will let you look at the last lines of a file
Grep lets you search through a file for instances you want to find
Both are available as part of Unix/Linux and should be part of your essential toolkit.