Changing File Time and Size rotation of Jenkins periodic Tasks

Issue

  • Jenkins tasks logs (files under $JENKINS_HOME/logs/) are growing big, 100 MB or more

Environment

Explanation

Jenkins periodic tasks log are stored under the log root directory that defaults to $JENKINS_HOME/logs. The files are rotated once a day and up to 6 files are kept. But files are not limited in size. At least until JENKINS-64151: Adjust file size rotation for AsyncPeriodicWork / AsyncAperiodicWork Task Logs is resolved.

Note: If a specific task is generating a lot of logs, it is usually indicative of a problem with that particular task and an issue must be logged.

Related Issue(s)

Resolution

There are ways to control the rotation via system properties (see How to add Java arguments to Jenkins and avoid disk space issues if a specific task generates too much log.

Change the Time rotation of all tasks

To change the default time rotation in minutes of all tasks - that is 1440 minutes (1 day) by default) - set the system property hudson.model.AsyncPeriodicWork.logRotateMinutes and hudson.model.AsyncAperiodicWork.logRotateMinutes on startup. For example, change the default file time rotation of all tasks to 12 hours: -Dhudson.model.AsyncPeriodicWork.logRotateMinutes=720 and -Dhudson.model.AsyncAperiodicWork.logRotateMinutes=720.

Change the Time rotation of a specific tasks

To change the time rotation in minutes of a specific task - that is 1440 minutes (1 day) by default - set the system property <FullyQualifiedClassName>.logRotateMinutes on startup. For example, change the hudson.model.WorkspaceCleanupThread file time rotation to 12 hours: -Dhudson.model.WorkspaceCleanupThread.logRotateMinutes=720.

Change the Size rotation of all tasks

To change the default size rotation in bytes of all tasks - that is -1 (unlimited) by default - set the system property hudson.model.AsyncPeriodicWork.logRotateSize and hudson.model.AsyncAperiodicWork.logRotateSize on startup. For example, change the default file size rotation of all tasks to 10 MB: -Dhudson.model.AsyncPeriodicWork.logRotateSize=10485760 and -Dhudson.model.AsyncAperiodicWork.logRotateSize=10485760.

Change the Size rotation of a specific tasks

To change the size rotation in bytes of a specific task - that is -1 (unlimited) by default - set the system property <FullyQualifiedClassName>.logRotateSize on startup. For example, change the hudson.model.WorkspaceCleanupThread file size rotation to 10 MB: -Dhudson.model.WorkspaceCleanupThread.logRotateSize=10485760.

Change the default location of all tasks

To change the default log root location in Jenkins - that is $JENKINS_HOME/logs by default - set the system property hudson.triggers.SafeTimerTask.logsTargetDir.

Have more questions?

0 Comments

Please sign in to leave a comment.