36

I am using Ubuntu 12.04.4 LTS 64 bit. My LibreOffice suite (especially Writer) freezes.

How can I kill LibreOffice and Can I kill only the writer? (not the Calc,Impress,..)

I tried to search for the executable process at System Monitor and command line (ps) but didn't find it.

EDIT: I want something like this:

pkill -9 writer

I need some kind of minified command.

1
  • But why -9? It is better to use -9 only when you know what you are doing. Nov 24, 2021 at 8:43

7 Answers 7

52

First search for open libreoffice files:

ps aux | grep libre

For example the output of mine is:

hadi  21426  0.1  0.0 205328  3468 ?        Sl   14:17   0:00 /usr/lib/libreoffice/program/oosplash --writer
hadi  21445  9.8  0.7 1269272 179872 ?      Sl   14:17   0:01 /usr/lib/libreoffice/program/soffice.bin --writer --splash-pipe=6

then

sudo kill -9 ID

the ID is the second number for (soffice.bin) not for oosplash

so in my example:

sudo kill -9 21445

You need professional Ok:

ps aux | grep -i office | awk {'print $2'} | xargs kill -9

hope this is professional in your evaluation!!

or more minified command

kill -9 `pgrep -lf soffice.bin | awk {'print $1'}`

or more minified minified minified command

pkill soffice.bin

EDIT:

All libreoffice open files take the same PID, for that you can't just kill writer and keep impess for example.

And to prove my point of view the recovery tool in office is unique for all files. What i mean if you close a writer in imporper way and then open an impress for example then impress will request you to recovery the writer file and it did so and this proves my answer

10
  • no when killing soffice it will kill all libreoffice programs when opened , try to open impress and writer and kill this process it will kill them both, it is a parent process
    – nux
    Mar 12, 2014 at 12:22
  • op needs just to kill writer , maybe he use to open calc and impress with writer :)
    – nux
    Mar 12, 2014 at 12:25
  • @nux YES that's someone who understands my need
    – kamil
    Mar 12, 2014 at 12:26
  • You can't do it. All libreoffice open files take the same PID.
    – Maythux
    Mar 12, 2014 at 12:29
  • Open writer and impress and calc and then ps aux|grep office and you'll see that no entries for other than writer. Since all files inherit the same PID.
    – Maythux
    Mar 12, 2014 at 12:29
9

You should try:

killall soffice.bin
2

use ps -e to list all processes running (not just those spawned by your current terminal). You can then search for the name you are looking for (Perhaps 'writer' or 'Libre'). If you know exactly the name you're looking for you could use ps -e | grep writer to give you the results for that process only.

You should see a number which is the process id (PID). To kill the process, enter kill x where x is the PID of the process. You should get a message saying something along the lines of killed 1 process. If the process is still running, try kill -KILL x to force the program to quit.

4
  • 1
    it doesn't work my dear
    – kamil
    Mar 12, 2014 at 12:27
  • Which bit didn't work?
    – Hugo Buff
    Mar 12, 2014 at 12:28
  • ps -e | grep writer doesn't return anything
    – kamil
    Mar 12, 2014 at 12:31
  • 1
    You'll have to just use ps -e and search through the names for the right process. writer was just a guess.
    – Hugo Buff
    Mar 12, 2014 at 12:33
1

Using killall

I usually just get away with killing oosplash

killall oosplash

or soffice.bin

killall soffice.bin

oosplash shows up higher in the pstree -p.

Using pstree

This function can be placed in your .bashrc file as a shortcut command. It searches the output of pstree -p for the PID of your search term.

piddler(){
    searchTerm=$1
    echo "Searching for ${searchTerm} processes:" 
    pstree -p | grep -oE "([a-zA-Z.-])*${searchTerm}([a-zA-Z.-])*\([0-9]{3,7}\)" | grep -oE "[a-zA-Z]([a-zA-Z.-])*\([0-9]{3,7}\)"
}

You can use it to find a system process like this:

piddler office

It'll output something like this:

Searching for office processes:
soffice.bin(8707)

Then you can kill the process with:

kill -9 8707
0

In a makefile

In a makefile, error messages can be avoided with either:

-killall -q oosplash

or

-@killall oosplash

The characters in front of the killall command do the trick.

However, even more gracefully would be:

-@wmctrl -c LibreOffice

or, even safer:

-@wmctrl -c filename
0

I had this problem, when I opened second document in LO Writer. I was not able to close not only LO, but anything, even UBUNTU. A simple, not ideal solution was:

  • Open Terninal
  • shutdown

When I opened the UBUNTU and LO again, it asked me, if I want to save the last document before the crash. My answer was (to be careful) no. Then I had no problem.

0

Usung killall -e

As Thomas Nyman said in https://unix.stackexchange.com/a/91540/382418

killall somewhat safer to use compared to pkill

Therefore i use: killall -e soffice.bin using (kUbuntu 20.4)

The -e, --exact option can be specified to also require exact matches for names longer than 15 characters.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .