当我通过管道读取 icecast 日志以过滤掉一个 vhost 时,我从 AWStats 7.2 cron 作业(在 Ubuntu 14.04 上,使用股票 awstats 包)收到此错误:
Error while processing /etc/awstats/awstats.mysite.conf
Create/Update database for config "/etc/awstats/awstats.mysite.conf" by AWStats version 7.2 (build 1.992)
From data in log file "grep '\/mysite' < /var/log/icecast2/access.log |"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Error: Command for pipe 'grep '\/mysite' < /var/log/icecast2/access.log |' failed
Setup ('/etc/awstats/awstats.mysite.conf' file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in 'docs' directory).
从表面上看,这似乎是一个简单的权限问题,但配置文件和日志文件都可以由www-data
运行此程序的用户读取。如果我进入该用户帐户,我可以毫无问题地读取这两个文件。
#sudo -u www-data ls -al /etc/awstats/awstats.mysite.conf /var/log/icecast2/access.log
-rw-r--r-- 1 www-data www-data 444 May 13 11:23 /etc/awstats/awstats.mysite.conf
-rw-r--r-- 1 icecast2 icecast 0 Jun 8 05:29 /var/log/icecast2/access.log
如果我在同一用户下运行 grep 命令,那也能正常工作。
为了避免出现虚假问题,我禁用了所有插件 - 我只使用 geoip,所以设置非常简单。如果我手动运行 awstats 命令并显示完整--debug=6
输出,看起来它在读取文件时没有任何问题 - 关闭文件时会抛出错误。实际上,这个日志文件目前是空的,所以没有什么可分析的,但这肯定不会产生权限错误吧?
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Start Update process (lastprocesseddate=201505)
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Open log file "grep '\/mysite' < /var/log/icecast2/access.log |"
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Sat Jun 13 20:33:21 2015 - DEBUG 1 - _host_p:0 _host_h:0 _host_k:0 _host_l:0 _host_s:0 _host_u:0
Sat Jun 13 20:33:21 2015 - DEBUG 1 - _url_p:0 _url_k:0 _url_e:0 _url_x:0
Sat Jun 13 20:33:21 2015 - DEBUG 1 - _waithost_e:0 _waithost_l:0 _waithost_s:0 _waithost_u:0
Sat Jun 13 20:33:21 2015 - DEBUG 1 - End of processing log file (AWStats memory cache is TmpDNSLookup=0 TmpBrowser=0 TmpOS=0 T
mpRefererServer=0 TmpRobot=0)
....(lots of stuff that seems related to successful processing and output deleted)
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Update offset of section sider_404=10022 in file at offset 1381
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Update MonthVisits=290 in file at offset 2140
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Update MonthUnique=168 in file at offset 2173
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Update MonthHostsKnown=0 in file at offset 2210
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Update MonthHostsUnknown=182 in file at offset 2249
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Call to Init_HashArray
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Close log file "grep '\/mysite' < /var/log/icecast2/access.log |"
Sat Jun 13 20:33:21 2015 - DEBUG 1 - Command for pipe 'grep '\/mysite' < /var/log/icecast2/access.log |' failed
我错过了什么?