Network and Storage Protocols

Closing Open CIFS files via command line



I'm trying to work out a way to close down open files that are open via CIFS.

We use some of our nas storage for home drives, which hold users email system files. (lotus notes).

If we suffer any slowdowns at logon then we'll see a large number of them getting some of these notes files locked open and they need closing off by an admin before the user can get into their emails.

This is currently done via MMC and finding the open files.

Does anyone know of a way to do this from command line ??   I'd like to script up a tool to do this with a set file path rather than do each one through a gui everytime.

I've tried the lock break -f command without any success.




You could break the files by protocol or by files/owner:

1. First find out needs to be broken, per user:

lock status -o owner [-f file] [-p protocol] [-n] (valid for CIFS only)


owner = [domain\]username          (CIFS)

protocol = cifs

2. then break

lock status break -o owner [-f file] [-p protocol] [-n] (valid for CIFS only)


If you want to reset all CIFS locks you can:

lock break -p cifs

I d recommend you do some testing if you can first and make a call if you want to break per protocol or client.



thanks Eric,

I'll give it a test but I'm not sure it will be usable in my scenario as I specifically want to close 1 single open file.

My users are quite likely to have other open files they want but if it works I can always procedurise it get round that step and get them to save any work first.


If you notice the options for lock command you will find that there you have to supply file path in /vol/volname/qtree/directory/file...... format so it will break lock only for that specific file and not for all users. if you wish you can also look into man pages for detailed information however here's the command you would like to run.

lock break -p cifs -f /vol/vol1/qtree1/somefile.doc


Lock break -p cifs also wroks for when CIFS fails to terminate which can  hamper reboots Cf takeover or upgreades etc.....


i would recommend you to use following way: on windows PC uner admin accound make cmd

1. openfiles /Query /S server_name |findstr /n /r /i problem_file_name.txt

and you will get  ID 

2. openfiles /disconnect /S severname /ID your_number