Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /homepages/8/d352291751/htdocs/sql313/site/libraries/vendor/joomla/application/src/Web/WebClient.php on line 406
Who has the #@!*$% file open?

Who has the #@!*$% file open?

Capacity/ Storage

I just found out about a nifty tool and thought I would share.

Scenario: The nightly ETL uses files as source data to insert into the data warehouse. The ETL failed because the file was locked and not accessible. The file is on a server in a shared folder. I needed to find out who had the file open, although I had a suspicion it was sql agent, not an actual person. Either way, the file needed to be closed, or the connection terminated.

Answer: openfiles.exe

I had never heard of this utility, but it works wonders. It was able to tell me who had the file open and allow me to disconnect the user's session with that file. In my case, the ETL was able to run successfully again. :) I did find out afterwards that our IT department performed maintenance over the weekend which must have caused the connection to 2 of these files to be "hung up".

The link above shows all the options available, but here is a summary also.

You can access the following information on the local server/workstation, or from remote. If you are remotely querying/disconnecting, then use the following switch:

You can perform all of these functions as yourself, or specify a specific user. You can use the following switches to indicate a specific user:

List of files open and by whom
/query

Terminate the connection
/disconnect

Note: I tried to disconnect the files using the ID specified from the /query switch. However, it didnt disconnect as I expected. When I tried the /o Read/Write, it did work as expected and closed all files.  Also, when looking at files on a software share, you can use the ip address.

Hope this helps someone - I am sure I will be referring back to my own blog for this one a few times!

Related Articles