Michael
Michael

Reputation: 10303

How to get rid of /tmp/.java_pid<number> files in Linux?

I noticed a lot of file /tmp/.java_pid<...> in my Linux machine. The file command says they are sockets. Assuming they are created by Java I wonder why Java does not clean them up. How to make Java clean them up or just not create them?

Upvotes: 4

Views: 5374

Answers (2)

Anya Shenanigans
Anya Shenanigans

Reputation: 94584

These files are created by the JVM to support debugging. It's part of the attach api.

If you don't want java to create them then start java apps without debugging enabled.

You can safely delete them if there isn't a jvm with the corresponding pid... a task that is eminently suitable for a cron job.

A little bit of bash:

for file in /tmp/.java-[0-9]*; do
  [ -d /proc/${file#*.java-} ] || rm -f $file
done

Upvotes: 7

Hendrik
Hendrik

Reputation: 1365

pid files are generally the location where applications store their process id, so the user can kill the process easily afterwards. These applications should be deleting these files when they close down.

I wouldn't worry about these files too much, unless you are seeing more and more of them and they dont get deleted, then it might be a tell tale sign that you have an application that is not shutting down correctly,

Upvotes: 1

Related Questions