Find all locked files

How to can find all locked files and release the locks in Unix?
We have an issue were an ftp job lands files under /home/loginid at 5:30 pm and at 6 pm we run a get file on the mvs mainframe machine ftp the file from the server to the mainframe. We get an error file is in use eventhu it is not !! However if we wait until next day morning the it works fine !!! Thanks

Well, fuser tells you if anyone else has it open. Not sure anyone has a lock scanner. The fcntl() call can ask if a lock is possible, so it can detect locks, but does not actually display locks. Ditto for lockf() F_TEST. I guess you could write an app to stat a file name from the command line and fcntl f_GETLK the whole file for either read or write per command line options.

Another possibility is that the ftp process has not completed by 6pm. The new file will show up in an 'ls' listing as soon as it is opened for writing, unlike MS operating systems where it does not show until the file is closed.

Yes, fuser is good for making sure transfers are complete, but better is that the other end send to a temp name, and if it transfers OK, renames it to the delivery name. A transfer processs may exit for a connection loss in mid-file. Trailers are nice, too, or XML completeness of outer element. Adding an ack/flag file is also effective, but seems a bit crude.

lol

I use that technique, but put the size of the main file as the contents of the flag file. Not all files conveniently have identifiable trailer records.