如何在系统启动时对自定义日志文件进行logrotate

问题描述 投票:-1回答:1

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

在根目录中,我有类似这样的内容:

@reboot --force /etc/logrotate.conf

但是它不起作用。我正在研究Debian 10。

linux logging logrotate
1个回答
0
投票

我假设您说的是'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

© www.soinside.com 2019 - 2024. All rights reserved.