I need to enable the logrotate service with Jenkins in order to rotate its log files (/var/log/jenkins/jenkins.log). So, I configured a script in /etc/logrotate.d with right permissions:
/var/log/jenkins/jenkins.log {
hourly
copytruncate
missingok
rotate 8
compress
delaycompress
size 5G
}
The permissions are 644 and the owner is root as for every logrotate script.
The logrotate service works correctly but not for Jenkins. No log files are rotated!
So, I tried to insert the command directly in root's crontab:
0 * * * * logrotate --force /etc/logrotate.d/jenkins
But also this command doesn't work at all even if the cron service works correctly each hour as per cron logs:
cat /var/log/syslog | grep logrotate
[...]
Jun 4 09:00:01 CI-prod CRON[11794]: (root) CMD (logrotate --force /etc/logrotate.d/jenkins)
Jun 4 10:00:01 CI-prod CRON[525]: (root) CMD (logrotate --force /etc/logrotate.d/jenkins)
However, if I manually execute the logrotate command (logrotate --force /etc/logrotate.d/jenkins), it works well and the Jenkins logs are rotated with no problem as per script.
Please, can you help me?
Here are other useful info:
- OS: Ubuntu 16.04.1 LTS
- Jenkins version: 2.121.2
- Java version: 1.8.0_121