gpt4 book ai didi

linux - 如何在系统启动时记录旋转自定义日志文件

转载 作者:太空宇宙 更新时间:2023-11-04 05:08:09 25 4
gpt4 key购买 nike

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

在 root crontable 中我有这样的东西:

@reboot --force /etc/logrotate.conf

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

最佳答案

当您说“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

关于linux - 如何在系统启动时记录旋转自定义日志文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58597619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com