logrotate - 文件所有者问题

logrotate - 文件所有者问题

我想轮换系统日志以进行测试。

sudo logrotate -f /var/log/syslog
[sudo] password for stephen: 
error: Ignoring /var/log/syslog because the file owner is wrong (should be root or user with uid 0).

主人是这样的:

ll /var/log/syslog
-rw-r----- 1 syslog adm 268K 2020-08-01 08:39 /var/log/syslog

好的,但是让我们尝试使用 root shell。

#echo $UID
0
#logrotate -f /var/log/syslog
error: Ignoring /var/log/syslog because the file owner is wrong (should be root or user with uid 0).

错误在哪里?解决方法是什么?

答案1

用法:logrotate [-dfv?] [-d|--debug] [-f|--force] [-m|--mail=command] [-s|--state=statefile] [-v|--verbose] [-l|--log=logfile] [--version] [-?|--help] [--usage] [OPTION...] < configfile >

sudo logrotate -f /etc/logrotate.conf

它必须在配置文件上运行...这将在配置指定的所有日志上运行 logrotate。

相关内容