Thursday, November 4, 2010

How to monitor file descriptor

  In Java development often I faced an issue with deleting files which was acquired by another processes. When you have 1 JVM, everything is fine, you can just kill it. In case of 20 Java processes things become complicated.
In linux there is an amazing file descriptor monitoring tool fuser, which return pid of process, which uses current file. As an alternative you can use lsof which returns list of all open descriptors.

#fuser foo.bar
#lsof bar.baz | grep ...

  In windows things are little bit complicated. One way is to install cygwin and use the earlier mentioned approach. Another solution is handle tool from sysinternals, which basically do the same thing as fuser. You can download it from microsoft website.

#handle -u  foo.bar

0 comments:

Post a Comment