I have a Docker image for cron tasks. Here is the Dockerfile:
FROM php:8.0-fpm
RUN apt-get update
RUN apt-get install -y cron rsyslog
RUN touch /var/log/cron.log
RUN chmod 0777 /var/log/cron.log
COPY ./app /var/www/app
COPY crontab /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab
RUN crontab /etc/cron.d/crontab
COPY 02-cron.conf /etc/rsyslog.d/02-cron.conf
CMD service rsyslog start && service cron start && tail -f /dev/null
By default rsyslog logs cron to /var/log/syslog. I want to log cron to a separate file /var/log/cron.log.
rsyslog's master config /etc/rsyslog.conf has the following lines:
*.*;auth,authpriv.none -/var/log/syslog
#cron.* /var/log/cron.log
I want to disable logging cron to /var/log/syslog and enable logging it to /var/log/cron.log by adding one more config /etc/rsyslog.d/02-cron.conf:
*.*;cron,auth,authpriv.none -/var/log/syslog
cron.* /var/log/cron.log
But the result is that cron logs to both /var/log/syslog and /var/log/cron.log.