I have a Docker image for cron tasks. Here is the Dockerfile:
FROM php:8.0-fpmRUN apt-get updateRUN apt-get install -y cron rsyslogRUN touch /var/log/cron.logRUN chmod 0777 /var/log/cron.logCOPY ./app /var/www/appCOPY crontab /etc/cron.d/crontabRUN chmod 0644 /etc/cron.d/crontabRUN crontab /etc/cron.d/crontabCOPY 02-cron.conf /etc/rsyslog.d/02-cron.confCMD 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/syslogcron.* /var/log/cron.log
But the result is that cron logs to both /var/log/syslog and /var/log/cron.log.