# Log Rotation does not work

**URL:** <https://community.jenkins.io/t/log-rotation-does-not-work/515>\
**Category:** Ask a question\
**Tags:** question\
**Created:** [October 12, 2021, 8:47am UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515 "2021-10-12T08:47:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haseneder](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@Haseneder](https://community.jenkins.io/u/Haseneder)\
**Post date:** [October 12, 2021, 8:47am UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/1 "2021-10-12T08:47:10Z")

</div>

Hello,

I have taken over a project and find that old jobs are not discarded which fills up disk space.  
As a consequence I have to delete old jobs from time to time.  
Jenkins version is 2.190.3.

Is there maybe some particular detail that I might not have considered ?

BR  
Rainer

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [October 12, 2021, 12:41pm UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/2 "2021-10-12T12:41:39Z")

</div>

The jobs are probably not configured to remove their old logs. Build discarder is not enabled by default.

The [“Configuration slicing plugin”](https://plugins.jenkins.io/configurationslicing/) will allow you modify the definitions of many jobs with a single operation. That may help you free some disc space.

---

<div class="post-metadata">

**Author:** ![Haseneder](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@Haseneder](https://community.jenkins.io/u/Haseneder)\
**Post date:** [October 12, 2021, 1:05pm UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/3 "2021-10-12T13:05:43Z")

</div>

The build discarder is enabled.  
I have attached a little screenshot.

 ![2021-10-12_jnkNRT_Log_Rotation_enabled](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/1X/7748ae9b5c6f02fce55bab9a08db10bdcc49ee12.png)

Is there another place I can check ?

Thanks  
Rainer

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [October 12, 2021, 1:11pm UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/4 "2021-10-12T13:11:15Z")

</div>

I use

```bash
$ du -x $JENKINS_HOME | sort -r -n | less

```

to show where the disc space is being used, and then investigate the jobs or other data sources that are using that disc space. If all the jobs are configured to discard builds after 3 days, then there may be other issues. In any case, finding the source of high disc use will let you decide your next action.

---

<div class="post-metadata">

**Author:** ![Haseneder](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@Haseneder](https://community.jenkins.io/u/Haseneder)\
**Post date:** [October 12, 2021, 1:19pm UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/5 "2021-10-12T13:19:32Z")

</div>

Thanks,  
we have already identified the job that consumes a lot of disk space  
and thus we wish Jenkins deleted jobs that are older than 3 days,  
but we have found that log rotation does not work.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [October 12, 2021, 3:03pm UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/6 "2021-10-12T15:03:18Z")

</div>

I’m not aware of any bug report that declares that log rotation does not work. Of course, you’re running a Jenkins version that was released two years ago and has been superseded by multiple releases with security fixes in Jenkins core and likely in the Jenkins plugins that you are using.

You may need to remove the old build logs yourself with file system commands if the build discarder is unable to do it.

---

<div class="post-metadata">

**Author:** ![Haseneder](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@Haseneder](https://community.jenkins.io/u/Haseneder)\
**Post date:** [October 12, 2021, 3:37pm UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/7 "2021-10-12T15:37:28Z")

</div>

Thank you Mark.  
Indeed we are going to upgrade soon and I will check again.

---

<div class="post-metadata">

**Author:** ![halkeye](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/halkeye/32/8_2.png) [@halkeye](https://community.jenkins.io/u/halkeye)\
**Post date:** [October 12, 2021, 4:59pm UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/8 "2021-10-12T16:59:35Z")

</div>

also the days of old build only fires when the build is run, so build on day 4 will clean up logs from day 1.

I **think** the newer version of the plugin and core actually will go do it outside of the build cycle, but not 100% sure on that (I personally use # of builds, so never did a time based cleanup.

---

<div class="post-metadata">

**Author:** ![Haseneder](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@Haseneder](https://community.jenkins.io/u/Haseneder)\
**Post date:** [October 12, 2021, 5:23pm UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/9 "2021-10-12T17:23:55Z")

</div>

Good point !  
Whatever the behavior may be, we require a cleanup latest when a new build is launched in order to not use entirely up disk space.

---

<div class="post-metadata">

**Author:** ![Haseneder](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@Haseneder](https://community.jenkins.io/u/Haseneder)\
**Post date:** [October 17, 2021, 10:31am UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/10 "2021-10-17T10:31:38Z")

</div>

Problem has disappeared after we have performed a restart of Jenkins service.  
Issue closed.  
Thank you for your comments and attention.

---

<div class="post-metadata">

**Author:** ![danielbeck](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/danielbeck/32/89_2.png) [@danielbeck](https://community.jenkins.io/u/danielbeck)\
**Post date:** [October 18, 2021, 6:43am UTC](https://community.jenkins.io/t/log-rotation-does-not-work/515/11 "2021-10-18T06:43:11Z")

</div>

Old builds are discarded only when a build is finished in 2.190, i.e. you need space for N+1 builds.
