我需要在系统启动时进行日志轮转。我为 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
我是一名优秀的程序员,十分优秀!