Logrotation未通过cron作业在docker容器中运行

时间:2019-01-22 09:17:47

标签: docker cron logrotate

我设置了一个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。那也不起作用。

1 个答案:

答案 0 :(得分:0)

尝试像这样重写您的cron记录:

30 9    * * *   /usr/sbin/logrotate /etc/logrotate.d/apache2