我已将 /etc/logrotate.d/httpd 设置为:
/var/log/httpd/* {
rotate 3
size 10k
missingok
notifempty
sharedscripts
postrotate
service httpd restart
endscript
}
但是在我的 /var/log/httpd 中我有:
[root@localhost httpd]# ls -al
totale 200
drwxrwxrwx 2 root root 4096 30 ott 17:13 .
drwxr-xr-x 12 root root 4096 30 ott 17:11 ..
-rw-r--r-- 1 root root 0 30 ott 17:13 access_log
-rw-r--r-- 1 root root 329 30 ott 17:13 error_log
-rw-r--r-- 1 root root 86427 30 ott 17:20 ssl_access_log
-rw-r--r-- 1 root root 0 30 ott 17:13 ssl_error_log
-rw-r--r-- 1 root root 88443 30 ott 17:20 ssl_request_log
[root@localhost httpd]#
因此为了检查,我执行 logrotate -f /etc/logrotate.d/http 并得到:
[root@localhost httpd]# logrotate -f /etc/logrotate.d/httpd
Interruzione di httpd: [ OK ]
Avvio di httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
并且我在 /var/log/httpd 中正确获取:
[root@localhost httpd]# ls -al
totale 340
drwxrwxrwx 2 root root 4096 30 ott 17:21 .
drwxr-xr-x 12 root root 4096 30 ott 17:11 ..
-rw-r--r-- 1 root root 0 30 ott 17:13 access_log
-rw-r--r-- 1 root root 329 30 ott 17:21 error_log
-rw-r--r-- 1 root root 395 30 ott 17:21 error_log.1
-rw-r--r-- 1 root root 48809 30 ott 17:26 ssl_access_log
-rw-r--r-- 1 root root 103234 30 ott 17:21 ssl_access_log.1
-rw-r--r-- 1 root root 0 30 ott 17:13 ssl_error_log
-rw-r--r-- 1 root root 49541 30 ott 17:26 ssl_request_log
-rw-r--r-- 1 root root 105502 30 ott 17:21 ssl_request_log.1
[root@localhost httpd]#
但看起来 logrotate 不会在文件大小达到 10k 时自动触发,尽管手册上说“size”参数应该在达到大小后在每小时/每天/... 之前进行日志轮换。
有什么线索吗?
感谢大家!干杯 Luigi