我被困在了logrotate的神秘面前

我有两个logrotate文件:

/etc/logrotate.d/nginx-size

/var/log/nginx/*.log /var/log/www/nginx/50x.log { missingok rotate 3 size 2G dateext compress compresscmd /usr/bin/bzip2 compressoptions -6 compressext .bz2 uncompresscmd /usr/bin/bunzip2 notifempty create 640 nginx nginx sharedscripts postrotate [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` endscript }

/etc/logrotate.d/nginx-daily

spamassassin和spamc的不同结果

您在CentOS中没有Apache的权限错误

与来自软件包文件系统-3.2的文件冲突

ffmpeg将任何文件转换为任何文件

使用gdb 7支持debuggingPython程序需要什么?

/var/log/nginx/*.log /var/log/www/nginx/50x.log { missingok rotate 3 dateext compress compresscmd /usr/bin/bzip2 compressoptions -6 compressext .bz2 uncompresscmd /usr/bin/bunzip2 notifempty create 640 nginx nginx sharedscripts postrotate [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` endscript }

命令logrotate -d -v /etc/logrotate.d/nginx-size输出:

reading config file /etc/logrotate.d/nginx-size compress_prog is now /usr/bin/bzip2 compress_options is now -6 compress_ext is now .bz2 uncompress_prog is now /usr/bin/bunzip2 Handling 1 logs rotating pattern: /var/log/nginx/*.log /var/log/www/nginx/50x.log 2147483648 bytes (3 rotations) empty log files are not rotated,old logs are removed considering log /var/log/nginx/access.log log does not need rotating considering log /var/log/nginx/error.log log does not need rotating considering log /var/log/nginx/get.access.log log does not need rotating considering log /var/log/nginx/post.access.log log needs rotating considering log /var/log/www/nginx/50x.log log does not need rotating rotating log /var/log/nginx/post.access.log,log->rotateCount is 3 dateext suffix '-20141204' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' glob finding old rotated logs failed renaming /var/log/nginx/post.access.log to /var/log/nginx/post.access.log-20141204 creating new /var/log/nginx/post.access.log mode = 0640 uid = 497 gid = 497 running postrotate script running script with arg /var/log/nginx/*.log /var/log/www/nginx/50x.log : " [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` " compressing log with: /usr/bin/bzip2

ngnix-daily上的相同(正常)输出

如果我从根命令运行

logrotate -f /etc/logrotate.d/nginx-size

手动,它做所有的事情。 但! 它不会自动运行!

contab:

*/5 5-23 * * * root logrotate -f -v /etc/logrotate.d/nginx-size 2>&1 > /tmp/logrotate_size 00 04 * * * root logrotate -f -v /etc/logrotate.d/nginx-daily 2>&1 > /tmp/logrotate_daily

另外,files / tmp / logrotate_daily&/ tmp / logrotate_size总是空的..

Cron不要在/ var / log / cron中给我任何错误

Dec 4 14:45:01 (root) CMD (logrotate -f -v /etc/logrotate.d/nginx-rz-size 2>&1 > /tmp/logrotate_size ) Dec 4 14:50:01 (root) CMD (logrotate -f -v /etc/logrotate.d/nginx-rz-size 2>&1 > /tmp/logrotate_size )

dat的东西有什么问题?Centos 6.5 x86_64,Logrotate版本3.8.7(源代码)+ logrotate版本3.7.8(通过rpm)。

Thx提前。

ps -ef在Asterisk重启时崩溃

PHP chmod()在服务器上不起作用

最新单声道在centos上

无法在我的centOS中安装铬

在没有udev或libusb的Linux上的USB连接事件

这些cron行中的重定向不正确。 他们不会向这些文件输出错误信息。

重定向顺序很重要。 你想>/tmp/logrotate_size 2>&1来得到你想要的。

这里的底层问题是cron信息页面的“调试crontab”部分所涵盖的内容之一。

即“对环境做出假设”。

对环境做出假设

图形程序(X11应用程序),Java程序,ssh和sudo作为cron作业运行是出了名的问题。 这是因为它们依赖于cron环境中可能不存在的交互式环境中的东西。

为了更紧密地模拟cron的环境,运行

env -i sh -c'yourcommand'

这将清除所有的环境变量,并运行sh可能更加微不足道的功能,你当前的shell。

通过这种方式发现的常见问题:

foo:找不到命令或只找到foo:找不到。

最可能的$ PATH被设置在你的.bashrc或类似的交互式init文件中。 尝试通过完整路径指定所有命令(或者在您要运行的脚本的开头放置source〜/ .bashrc)。

相关文章

Git安装和使用 Git安装和使用 刚开始用git的小白适用,,转自...
fatal: remote origin already exists.解决方法 第一个问题g...
git常用命令(二)查看历史记录 git log [--pretty=oneline]...
git之如何把本地文件上传到远程仓库的指定位置 git专栏收录该...
代码规范之 lint-staged 在代码提交之前,进行代码规则检查能...
方法:1、文件没有git操作时用“git checkout--文件”命令还...