【问题标题】:How to logrotate custom log file on system boot如何在系统启动时 logrotate 自定义日志文件
【发布时间】:2019-10-28 19:59:17
【问题描述】:

我需要在系统启动时登录。我为 logrotate 创建了一个自定义配置来压缩文件。 @reboot 的解决方案不起作用。

在根 crontable 我有这样的东西:

@reboot --force /etc/logrotate.conf

但它不起作用。我正在开发 Debian 10。

【问题讨论】:

    标签: linux logging logrotate


    【解决方案1】:

    当您说“crontable”时,我假设您的意思是 crontab,在这种情况下,您的格式不正确。根据 crontab 手册页 (1):

    These special time specification "nicknames" are supported, 
    which replace the 5 initial time and date fields, and are prefixed by the '@' character:
    
    @reboot    :    Run once after reboot.
    

    @reboot 昵称只替换了 5 个时间/日期字段;您仍然需要遵循有关如何在 crontab 中格式化命令的规则(同样,来自手册页):

    <date fields> <user to run command as> <command to run>

    例如,

    30 12 * 8 * root touch /tmp/file

    因此,如果您想使用 @reboot 昵称,您应该替换的只是字符串开头的五个时间/日期字段,例如

    @reboot root touch /tmp/file

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-28
      • 2016-04-03
      • 2014-04-22
      • 2012-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多