简体   繁体   中英

/var/log/folder permissions change automatically everyday

I am on a ubuntu machine and writing into a log folder /var/log/APP through cron.daily. The log folder is owned by APP user and needs permissions set as 755 to get the job done. I had to set the permissions of the folder to 755 again and again after finding the permissions being automatically changed to 700.

What can be the possible causes for this kind of behavior?

Content of cron.daily:

00 22 * * 1-5 app app ARG > /var/log/APP/APP.$(date +"\%Y-\%m-\%d").log 2
35 13 * * 2-7 app app ARG > /var/log/APP/APP.$(date +"\%Y-\%m-\%d").log 2

Not 100% sure, but I would guess that you have a logrotate rule set up for this folder. If it's a common application like Apache or MySQL, and you're running a common Linux distro, this is very likely.

Depending on your distro, you should have either a file /etc/logrotate.conf , or a directory /etc/logrotate.d/ with one file per service, or even both.

Check these files if there are rules for the directory in question. If you need the directory to be owned by a different user, you can use the create directive of logrotate (or modify it, if it exists).

But make sure that the original service writing the logs is still able to do so.

I faced the same issue. It's mostly because of the permission issue associated with the file /var/lib/dpkg/info/nginx-common.postint

Change the chmod 640 "$access_log" to chmod 655 "$access_log" in both the access_log and error_log

And it's done! Refer to this link for more info https://askubuntu.com/questions/794759/annoying-access-problem-on-var-log-nginx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM