用logrotate管理apache日志出错

回复 收藏
在logrotate.d下创建了如下文件
  1. # cat /etc/logrotate.d/httpd
  2. /usr/local/apache2/logs/discuz-error_log {
  3.     weekly
  4.     create 0644 root root
  5.     minsize 1M
  6.     rotate 1
  7.     prerotate
  8.         /usr/local/apache2/bin/apachectl graceful
  9.     endscript
  10. }
  11. /usr/local/apache2/logs/discuz-access_log {
  12.     daily
  13.     create 0644 root root
  14.     rotate 5
  15.     prerotate
  16.         /usr/local/apache2/bin/apachectl graceful
  17.     endscript
  18. }
测试时,却报如下错误
  1. # logrotate -vf /etc/logrotate.d/httpd
  2. reading config file /etc/logrotate.d/httpd
  3. reading config info for /usr/local/apache2/logs/discuz-error_log
  4. reading config info for /usr/local/apache2/logs/discuz-access_log
  5. Handling 2 logs
  6. rotating pattern: /usr/local/apache2/logs/discuz-error_log  forced from command line (1 rotations)
  7. empty log files are rotated, only log files >= 1048576 bytes are rotated, old logs are removed
  8. considering log /usr/local/apache2/logs/discuz-error_log
  9.   log needs rotating
  10. rotating log /usr/local/apache2/logs/discuz-error_log, log->rotateCount is 1
  11. dateext suffix '-20160201'
  12. glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  13. renaming /usr/local/apache2/logs/discuz-error_log.1 to /usr/local/apache2/logs/discuz-error_log.2 (rotatecount 1, logstart 1, i 1),
  14. old log /usr/local/apache2/logs/discuz-error_log.1 does not exist
  15. renaming /usr/local/apache2/logs/discuz-error_log.0 to /usr/local/apache2/logs/discuz-error_log.1 (rotatecount 1, logstart 1, i 0),
  16. old log /usr/local/apache2/logs/discuz-error_log.0 does not exist
  17. log /usr/local/apache2/logs/discuz-error_log.2 doesn't exist -- won't try to dispose of it
  18. running prerotate script
  19. Syntax error on line 34 of /usr/local/apache2/conf/extra/httpd-vhosts.conf:
  20. Invalid command 'Indexes', perhaps misspelled or defined by a module not included in the server configuration
  21. error: error running non-shared prerotate script for /usr/local/apache2/logs/discuz-error_log of '/usr/local/apache2/logs/discuz-error_log '
  22. rotating pattern: /usr/local/apache2/logs/discuz-access_log  forced from command line (5 rotations)
  23. empty log files are rotated, old logs are removed
  24. considering log /usr/local/apache2/logs/discuz-access_log
  25.   log needs rotating
  26. rotating log /usr/local/apache2/logs/discuz-access_log, log->rotateCount is 5
  27. dateext suffix '-20160201'
  28. glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  29. renaming /usr/local/apache2/logs/discuz-access_log.5 to /usr/local/apache2/logs/discuz-access_log.6 (rotatecount 5, logstart 1, i 5),
  30. old log /usr/local/apache2/logs/discuz-access_log.5 does not exist
  31. renaming /usr/local/apache2/logs/discuz-access_log.4 to /usr/local/apache2/logs/discuz-access_log.5 (rotatecount 5, logstart 1, i 4),
  32. old log /usr/local/apache2/logs/discuz-access_log.4 does not exist
  33. renaming /usr/local/apache2/logs/discuz-access_log.3 to /usr/local/apache2/logs/discuz-access_log.4 (rotatecount 5, logstart 1, i 3),
  34. old log /usr/local/apache2/logs/discuz-access_log.3 does not exist
  35. renaming /usr/local/apache2/logs/discuz-access_log.2 to /usr/local/apache2/logs/discuz-access_log.3 (rotatecount 5, logstart 1, i 2),
  36. old log /usr/local/apache2/logs/discuz-access_log.2 does not exist
  37. renaming /usr/local/apache2/logs/discuz-access_log.1 to /usr/local/apache2/logs/discuz-access_log.2 (rotatecount 5, logstart 1, i 1),
  38. old log /usr/local/apache2/logs/discuz-access_log.1 does not exist
  39. renaming /usr/local/apache2/logs/discuz-access_log.0 to /usr/local/apache2/logs/discuz-access_log.1 (rotatecount 5, logstart 1, i 0),
  40. old log /usr/local/apache2/logs/discuz-access_log.0 does not exist
  41. log /usr/local/apache2/logs/discuz-access_log.6 doesn't exist -- won't try to dispose of it
  42. running prerotate script
  43. Syntax error on line 34 of /usr/local/apache2/conf/extra/httpd-vhosts.conf:
  44. Invalid command 'Indexes', perhaps misspelled or defined by a module not included in the server configuration
  45. error: error running non-shared prerotate script for /usr/local/apache2/logs/discuz-access_log of '/usr/local/apache2/logs/discuz-access_log '
求解
2016-02-01 16:01 举报
已邀请:
0

starry

赞同来自:

本帖最后由 starry 于 2016-2-1 16:14 编辑

{:7_193:} 解决了 上面的报错信息 只是 在使用indexes参数时没加上Options参数
   
         Options Indexes
         Order deny,allow
         Deny from all
   


重新执行,日志切割成功
  1. # logrotate -vf /etc/logrotate.d/httpd
  2. reading config file /etc/logrotate.d/httpd
  3. reading config info for /usr/local/apache2/logs/discuz-error_log
  4. reading config info for /usr/local/apache2/logs/discuz-access_log

  5. Handling 2 logs

  6. rotating pattern: /usr/local/apache2/logs/discuz-error_log  forced from command line (1 rotations)
  7. empty log files are rotated, only log files >= 1048576 bytes are rotated, old logs are removed
  8. considering log /usr/local/apache2/logs/discuz-error_log
  9.   log needs rotating
  10. rotating log /usr/local/apache2/logs/discuz-error_log, log->rotateCount is 1
  11. dateext suffix '-20160201'
  12. glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  13. renaming /usr/local/apache2/logs/discuz-error_log.1 to /usr/local/apache2/logs/discuz-error_log.2 (rotatecount 1, logstart 1, i 1),
  14. old log /usr/local/apache2/logs/discuz-error_log.1 does not exist
  15. renaming /usr/local/apache2/logs/discuz-error_log.0 to /usr/local/apache2/logs/discuz-error_log.1 (rotatecount 1, logstart 1, i 0),
  16. old log /usr/local/apache2/logs/discuz-error_log.0 does not exist
  17. log /usr/local/apache2/logs/discuz-error_log.2 doesn't exist -- won't try to dispose of it
  18. running prerotate script
  19. renaming /usr/local/apache2/logs/discuz-error_log to /usr/local/apache2/logs/discuz-error_log.1
  20. creating new /usr/local/apache2/logs/discuz-error_log mode = 0644 uid = 0 gid = 0

  21. rotating pattern: /usr/local/apache2/logs/discuz-access_log  forced from command line (5 rotations)
  22. empty log files are rotated, old logs are removed
  23. considering log /usr/local/apache2/logs/discuz-access_log
  24.   log needs rotating
  25. rotating log /usr/local/apache2/logs/discuz-access_log, log->rotateCount is 5
  26. dateext suffix '-20160201'
  27. glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  28. renaming /usr/local/apache2/logs/discuz-access_log.5 to /usr/local/apache2/logs/discuz-access_log.6 (rotatecount 5, logstart 1, i 5),
  29. old log /usr/local/apache2/logs/discuz-access_log.5 does not exist
  30. renaming /usr/local/apache2/logs/discuz-access_log.4 to /usr/local/apache2/logs/discuz-access_log.5 (rotatecount 5, logstart 1, i 4),
  31. old log /usr/local/apache2/logs/discuz-access_log.4 does not exist
  32. renaming /usr/local/apache2/logs/discuz-access_log.3 to /usr/local/apache2/logs/discuz-access_log.4 (rotatecount 5, logstart 1, i 3),
  33. old log /usr/local/apache2/logs/discuz-access_log.3 does not exist
  34. renaming /usr/local/apache2/logs/discuz-access_log.2 to /usr/local/apache2/logs/discuz-access_log.3 (rotatecount 5, logstart 1, i 2),
  35. old log /usr/local/apache2/logs/discuz-access_log.2 does not exist
  36. renaming /usr/local/apache2/logs/discuz-access_log.1 to /usr/local/apache2/logs/discuz-access_log.2 (rotatecount 5, logstart 1, i 1),
  37. old log /usr/local/apache2/logs/discuz-access_log.1 does not exist
  38. renaming /usr/local/apache2/logs/discuz-access_log.0 to /usr/local/apache2/logs/discuz-access_log.1 (rotatecount 5, logstart 1, i 0),
  39. old log /usr/local/apache2/logs/discuz-access_log.0 does not exist
  40. log /usr/local/apache2/logs/discuz-access_log.6 doesn't exist -- won't try to dispose of it
  41. running prerotate script
  42. renaming /usr/local/apache2/logs/discuz-access_log to /usr/local/apache2/logs/discuz-access_log.1
  43. creating new /usr/local/apache2/logs/discuz-access_log mode = 0644 uid = 0 gid = 0
  44. # ls /usr/local/apache2/logs/
  45. access_log                discuz-access_log    discuz-error_log.1
  46. default-vhost-access_log  discuz-access_log.1  error_log
  47. default-vhost-error_log   discuz-error_log     httpd.pid


0

旅行

赞同来自:

路过

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: