Can I safely delete .~lock… files for Libreoffice documents that I know are now closed?

I have a situation where a .~lock file exists on my laptop when I know the file was closed.
Here’s how:
On my desktop, I edit a Libreoffice Writer file. Once I’ve finished, I sync the folder (using rsync -auv) with my external drive [one-way: files copied from desktop to USB drive but not vice versa] and then sync the external drive with my laptop [again, one-way – from USB to laptop only] – that’s how I keep up to date records on my laptop.

Occasionally I’ve done that sync when a document has been open. I’ve made no more changes and closed it, but obviously the .~lock file is in the folder that then syncs with the external drive then the laptop – so the lock file copies over to the laptop via the external drive.
Often a few weeks later, when I open the folder on my laptop, the .~lock file is there and Libreoffice says the file is locked for editing by me on a different computer.
I am certain that the file is not open on the other computer (and I won’t have made any edits after copying it over, so I’m confident the version on my laptop is the current version), it’s just that I synced it when the file was still open.

Obviously the solution is to ensure that all files are closed before I sync, but if I forget – and for the few files when I have previously done this – what’s the best solution? Is it safe just to delete the .~lock file? Does that file contain anything other than a flag to tell the system that the file is (potentially) open on another system / by another user and so editing it will cause conflicts?

Many thanks.

Asked By: Will


Yes, that is completely safe.

The only function of the ~lock file is to prevent two users on the same system (or even one user from two different systems) from modifying the same document at the same time. So if you know you are the only user involved, removing the lock is of no consequence.

I opened such a lock file to see what’s inside: my username, the name of the host, a date/time, and the path to the Libreoffice configuration file in use at the time. Nothing worth keeping, in other words.

Answered By: Jos
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.