Once in a while, I got into issues that my build failed because the IDE could not clean certain folder or file. The root cause was that they were opened by another application/process. If the application is known, just closed it and the build worked well. Some times I had no clue which application held the file. To find out quickly without guessing, right tools are needed.
On Linux, it’s quite easy with a command called lsof as follows:
Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.
# lsof /var/log/messages COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME syslogd 3476 root 2w REG 8,3 1480 21934417 /var/log/messages
By default, the lsof may not be installed upon typical installation. You can install it easily using package installer. The command on CentOS or Redhat is like the following:
# yum install lsof
On Windows, it’s not hard either if you have the right tool that I will introduce. The tool is called Process Explorer which can be downloaded from this Microsoft link. It’s a bit bigger than 1M in size and quite easy to install.
To find out which process opens a file, you can click Find – Find Handle or DLL menu item, or simply CTRL + F shortcut key. In the dialog box, just enter the path of the file or directory. Upon clicking on Search button, the application names show up in the table below. As with a typical Microsoft tool, you don’t need to think much about how to use it. As the name of the menu suggests, it also find out the applications that use a DLL file.