tmp directory not cleaning while using jenkins

Kaku picture Kaku · Jan 14, 2014 · Viewed 9.8k times · Source

I am using jenkins 1.451 on AIX 7.0 with job carrying out checkout,compile and pushing code to our environment.

Also a Sonar job is configured on jenkins. Here, Jenkins is not implemented using apache or as RPM. We have just extracted the war and are using 2-3 jobs to compile and push code. I know jenkins uses the tmp directory to run the jobs. I have seen following files in /tmp directory which I guess are left even job has finished.

PFB the names of files which are present in large number

1.xbean2456858964200604902.d
2.jetty-0.0.0.0-8080-jenkins.war-_jenkins-any-
3.sonar-batch21583185812212985831389617600951909000
4.winstone8285452915548449514.jar
5.fixcrlf1440303164

Is it normal to have such files in large number. How do we clean up these files ???

Thanks a lot

Answer

Vorsprung picture Vorsprung · Jan 15, 2014

Files in /tmp are unlikely to be harmful to delete. /tmp is cleared on reboot on most systems.

You could add another jenkins job with the build triggers set to "build after other projects are built" with a list of all the other projects

Then do a build "execute shell" command such as

find /tmp -user jenkins -print0 | xargs -0 rm -f

Where "jenkins" is the jenkins user name

If the user name is likely to be shared with other processes that also write temp files then you will need to force jenkins to write its temp files to a known, alternative destination by setting java.io.tmpdir