A month ago I set cron to log to
/var/log/cron.log by modifying
/etc/rsyslog.d/50-default.conf. Logging worked great until I changed permissions on
/var/log (by easing permission restrictions), and forced logrotate to rotate the logs by executing
logrotate --force /etc/rsyslog.d/50-default.conf. Since then, cron seems to have stopped logging. There is no longer a
/var/log/cron.log. I executed
sudo touch /var/log/cron.log to create it, but it has remained 0 bytes since.
More details on what I did with the permissions:
sudo chmod 775 /var/log, and subsequently changed permissions back with
sudo chmod 755 /var/log. All other services appear to be logging correctly, and cron jobs are actually running (verified with
ps aux | grep rsync, since I only run rsync via cron).
I wasn't sure of the correct user and group access rights for
cron.log so I tried changing it to
syslog:adm like most of the other log files, but that didn't help, so I switched it back to
Current permissions on cron.log:
-rwxr-xr-x 1 root root 0 Apr 27 16:34 cron.log
Not sure where to go from here. I know I can have cron log to any file I'd like (either by adding
>> /path/to/logfile to end of cron job entries or by editing
/etc/rsyslog.d/50-default.conf), but for consistency, I would prefer it continue logging to cron.log. I suppose I could add
>> /var/log/cron.log to the end of each cron entry, but that seems a little hacky to me.
EDIT: As per my comment below, I changed the log location to
/tmp/cron.logand logging has resumed. At first, I had assumed this implied that either the folder or file permissions are wrong. However, I checked them against another machine running the same distro, and the folder permissions were correct. The file permissions were not restrictive enough, the correct permissions can be set with
sudo chmod 640 cron.log.
As a test, I deleted the empty cron.log, and it was never recreated. I modified the rsyslogd config to have it log to crond.log, but the file was never created.