Ubuntu – How to unlock file, locked by a process

javalocklsof

The file is locked by a process, java in my case. I only want the lock to be released.

lsof | grep /home/user/workspace1

lsof

A temporary solution was to 'End Process' from 'System Monitor'.
End Process
But terminating java(Java Virtual Machine) would terminate all other programs using java. So how shall I release the lock held by any process. For the same purpose Windows has an application called 'Unlocker'.

Best Answer

Try lockf.

lockf - apply, test or remove a POSIX lock on an open file

The lockf() function allows sections of a file to be locked with advisory-mode locks. Calls to lockf() from other processes which attempt to lock the locked file section will either return an error value or block until the section becomes unlocked. All the locks for a process are removed when the process terminates. Record locking with lockf() is supported for regular files.IBM

Related Question