Jenkins.log or hudson.log log size limit

I use Hudson as well as Jenkins, and I have several works on them. From time to time, the hudson.log / jenkins.log file grows tremendously.

I know that the size of the same can be limited. Please help how to change and in which file the change should be made.

+6
source share
2 answers

You can use logrotate . You can find more information about logrotate in this kb article .

This is how logrotate configured on my system ( /etc/logrotate.d/jenkins ):

 /var/log/jenkins/jenkins.log /var/log/jenkins/access_log { compress dateext maxage 365 rotate 99 size=+4096k notifempty missingok create 644 postrotate if [ -s /var/run/jenkins.pid ]; then JPID=`cat /var/run/jenkins.pid` test -n "`find /proc/$JPID -maxdepth 0 -user jenkins 2>/dev/null`" && /bin/kill -s ALRM $JPID || : fi endscript } 

or if you don’t really like the signals and this is a failure for you, you can use the logrotate definition from this debian configuration .

 /var/log/jenkins/jenkins.log { weekly copytruncate missingok rotate 52 compress delaycompress notifempty } 
+4
source

Using logrotate with copytruncate does not release the lock on the file descriptor, and you get problems similar to what is mentioned in Sebastian Sastre, where the rotation takes place, but you will not get your disk space until you restart Jenkins.

As an alternative solution, this script could possibly be used in a postrotate block. It relies on gdb to send the close () function open (), which replaces the "broken" file descriptor.

+3
source

All Articles