Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Close Libreoffice gracefuly from command line

Hi,

I'm running LibreOffice 6 on multiple remote controlled linux (debian) computers. Now I'd like to close LibreOffice on every machine without manually closing it on multiple machines.

So I wrote as script that logs in to this machines using SSH and kills LibreOffice. This however has the problem that the lock files of the saved documents stays on our network share and other users aren't able to edit them afterwards. I tried several kill levels like "HUP" (nothing happens), "INT", "QUIT", "KILL" or "TERM". Everything kills LibreOffice immediately and won't remove the lock files. When you kill LibreOffice on Windows using the TaskManager it works as expected. No lock file afterwards, but on Linux it wont't.

To sum up the problem: I need to close LibreOffice without leaving a lock file with remote control. If the document is unsaved it doesn't matter if it get lost. It's intended in this case. Just disabling the lock file isn't an option.

How to solve this problem? - I tried using wmctrl and xdoctrl, but this isn't really reliable, because you don't know in which state the user leave the computer. - As mentioned kill wont't work. Maybe somebody has another way to solve it using kill?

I managed it to close the document using a Macro and the code:

ThisComponent.Close(true)

This worked, but I can't do it remotly. So one hacky solution would be to write an extension that is able to communicate with the underlying system and closes LibreOffice gracefully so it won't leave a lock file.' But this is very hacky and I don't like to do it this way.

So does anybody has a better solution how to solve this problem?