I am trying to write a simple script that monitors /var/log/messages
file. The file by default doesn't have read permission for users, when I allow read access to this file my script works perfectly, but the problem is that file gets rewritten each time I restart the system and all my changes get lost. Is there a way to change its default permissions?
Thanks.
Best Answer
There are permissions management setups that don't require you to use
sudo
-- you could give the user running the script access to the group that owns/var/log/messages
(adm
, on my laptop here). Alternately, useNOPASSWD
in the sudoers entry for the script, so that you don't have to store a password in the script.If you're really dead-set on letting the world see what's in
/var/log/messages
(and I'd strongly recommend against it -- there really can be private stuff in there) then what's setting your permissions back to default is probablylogrotate
, so check out your logrotate config and find the stanza that's doing your/var/log/messages
rotation and change it.