Logrotate日志切割报错 文件不再同一个用户组下

本文介绍了解决因目录权限不安全导致的日志文件轮转失败的问题。通过在配置文件中添加特定指令来指定正确的用户和组进行日志轮转。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

分割日志时报错:

error: skipping "/var/log/nginx/test.access.log" because parent
directory has insecure permissions (It's world writable or writable by
group which is not "root") Set "su" directive in config file to tell
logrotate which user/group should be used for rotation.

xx 文件所属用户

添加“su root xx”到/etc/logrotate.d/nginx文件中即可
如下;

/var/log/nginx/*.log {
        su root public
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        #ifempty
        create 0640 www-data adm
        sharedscripts
        postrotate
                [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
        endscript
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值