我设置了一个cronjob来在docker容器中运行logrotate。
/etc/crontab
文件:
30 9 * * * root /usr/sbin/logrotate /etc/logrotate.d/apache2
/etc/logrotate.d/apacha2
文件:
/var/log/apache2/*.log {
daily
missing
rotate 5
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}
Dockerfile: ... /一些内容/ ...... ........... ENTRYPOINT [“ /开始”]
start.sh:
#!/bin/bash
/etc/init.d/cron start
谁能建议我要去哪里错了? 我尝试在Dockerfile中使用“ RUN服务cron start”启动cron。那也不起作用。
答案 0 :(得分:0)
尝试像这样重写您的cron记录:
30 9 * * * /usr/sbin/logrotate /etc/logrotate.d/apache2