[英]Access permissions for directory in Linux
I have a programm which creates log files in web-server directory (/var/www/log). 我有一个在Web服务器目录(/ var / www / log)中创建日志文件的程序。 Every day it generates one new log file.
每天都会生成一个新的日志文件。 I've set access permissions for this directory to 777
我已将此目录的访问权限设置为777
chmod 777 -R /var/www/log
But when system generates log file for new day, it doesn't have access permissions 777. I have to do it manually again. 但是,当系统为新的一天生成日志文件时,它没有访问权限777。我必须再次手动进行操作。 How can I correctly set permissions for directory?
如何正确设置目录权限? All files in this directory must have 777 automatically.
此目录中的所有文件必须自动具有777。
syslog
instead. syslog
。 Every programming language has the option to log to syslog. runuser
or sudo
commands. runuser
或sudo
命令以root身份启动该软件, runuser
其特权授予该软件的专用用户。 This dedicated user could have write access to the log files. In general, I do not understand why all users must have access to all log files. 通常,我不明白为什么所有用户都必须有权访问所有日志文件。 Please elaborate that.
请详细说明。
For completeness: 为了完整性:
What most likely happens is that logrotate
kicks in. It is a tool compresses old and deletes outdated log files and creates new ones based on what is configured in /etc/logrotate.conf
and files included there. 最有可能发生的是
logrotate
启动。它是一个压缩旧工具,并删除过时的日志文件,并根据/etc/logrotate.conf
配置的内容以及其中包含的文件创建新的日志文件。 Otherwise your server would run out of space after a while. 否则,您的服务器将在一段时间后耗尽空间。 You can either change the configuration of logrotate or
您可以更改logrotate的配置,也可以更改
You could add a chmod 0777 -R /var/www/log
either to the crontab root or the various system crontabs. 您可以将
chmod 0777 -R /var/www/log
到crontab根目录或各种系统crontabs。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.