点击下载安装cronolog。
假设安装目录为:/usr/local/cronolog
cat access_log |/usr/local/cronolog/sbin/cronolog -p 12hours /home/test/%Y-%m-%d.log |
命令运行之后并无提示,在请求发生之后,会在/home/test/目录下生成Log文件。
cat access_log |/usr/local/cronolog/sbin/cronolog -p 13hours /home/test/%Y-%m-%d.log |
提示:/usr/local/cronolog/sbin/cronolog: invalid explicit period specification ((null))
这个需要看一下Cronolog文档说明,如下:
-p PERIOD--period=PERIODspecifies the period explicitly as an optional digit string followed by one of units: seconds, minutes,hours, days, weeks or months. The count cannot be greater than the number of units in thenext larger unit, i.e. you cannot specify "120 minutes", and for seconds, minutes and hours thecount must be a factor of the next higher unit, i.e you can specify 1, 2, 3, 4, 5, 6, 10, 15, 20 or 30minutes but not say 7 minutes. |
假设需要每4小时导出一次Log,则在http.conf里设置:
CustomLog "|/usr/local/cronolog/sbin/cronolog -p 4hours /home/test/%Y-%m-%d-%H.log" common |
注释原来apache配置文件中的CustomLog那一行。