小编Chr*_*ris的帖子

cron作业上的nginx logrotate错误

我在 Digital Ocean VPS 上运行 Ubuntu 14.04 LTS 和 nginx,偶尔会收到这些关于失败的 cron 作业的电子邮件:

主题

cron test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

电子邮件的正文是:

/etc/cron.daily/logrotate: 错误: 为'/var/log/nginx/*.log' 运行部分运行共享 postrotate 脚本时出错: /etc/cron.daily/logrotate 退出并返回代码 1

关于如何解决这个问题的任何想法?

更新:

/var/log/nginx/*.log {
  weekly
  missingok 
  rotate 52 
  compress 
  delaycompress
  notifempty 
  create 0640 www-data adm
  sharedscripts
  prerotate
      if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
          run-parts /etc/logrotate.d/httpd-prerotate; \
      fi
  endscript 
  postrotate 
      invoke-rc.d nginx rotate >/dev/null 2>&1
  endscript 
}
Run Code Online (Sandbox Code Playgroud)

更新:

$ sudo invoke-rc.d nginx rotate
initctl: …
Run Code Online (Sandbox Code Playgroud)

cron ubuntu logrotate nginx

11
推荐指数
2
解决办法
8141
查看次数

标签 统计

cron ×1

logrotate ×1

nginx ×1

ubuntu ×1