在 AMI Linux 2 上轮换自定义日志

发布于 2025-01-15 00:48:15 字数 1053 浏览 5 评论 0原文

我需要使用 Ruby 在 AMI Linux 2 上的 AWS Elastic Beanstalk 上轮换我的 Resque 日志。我的 Puma 和 Nginx 日志正常轮换。我在下面添加了以下配置,但日志没有轮换。

.ebextensions/03_publish-logs.config

files:
 "/opt/elasticbeanstalk/tasks/publishlogs.d/resque.conf" :
  mode: "000755"
  owner: root
  group: root
  content: |
    /var/log/resque/rotated/*

.ebextensions/04_rotate-logs.config

files:
 "/etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.resque.conf" :
  mode: "000755"
  owner: root
  group: root
  content: |
   /var/log/resque/* {
    su root root
    size 10M
    rotate 5
    missingok
    compress
    notifempty
    copytruncate
    dateext
    dateformat %s
    olddir /var/log/resque/rotated
   }

我正在关注此文档:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html#health-logs-logrotate

I need to rotate my Resque logs on AWS Elastic Beanstalk on AMI Linux 2 with Ruby. My Puma and Nginx logs rotate properly. I've added the following config below, but the logs are not getting rotated.

.ebextensions/03_publish-logs.config

files:
 "/opt/elasticbeanstalk/tasks/publishlogs.d/resque.conf" :
  mode: "000755"
  owner: root
  group: root
  content: |
    /var/log/resque/rotated/*

.ebextensions/04_rotate-logs.config

files:
 "/etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.resque.conf" :
  mode: "000755"
  owner: root
  group: root
  content: |
   /var/log/resque/* {
    su root root
    size 10M
    rotate 5
    missingok
    compress
    notifempty
    copytruncate
    dateext
    dateformat %s
    olddir /var/log/resque/rotated
   }

I'm following this documentation: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html#health-logs-logrotate

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦 2025-01-22 00:48:15

您忘记将此配置添加到 logrotate 中。

将此代码添加到 .ebextensions:

files:
  "/etc/cron.hourly/cron.logrotate.elasticbeanstalk.resque.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/bin/sh
      test -x /usr/sbin/logrotate || exit 0
      /usr/sbin/logrotate /etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.resque.conf

You forgot to add this config to logrotate.

Add this code to .ebextensions:

files:
  "/etc/cron.hourly/cron.logrotate.elasticbeanstalk.resque.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/bin/sh
      test -x /usr/sbin/logrotate || exit 0
      /usr/sbin/logrotate /etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.resque.conf
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文