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 }
source share