I have a php script in which I need to convert doc documents to html files in order to show them in a web page.

I'm doing the conversion with the php command:

exec ( $Command, $Output, $ReturnValue ) ;


$Command = "/usr/bin/timeout -s 9 $TimeOut /usr/bin/unoconv -f html -o " . escapeshellarg($Dir) . " " . escapeshellarg($File) ;

Apparently everything works well, but sometimes the process doesn't end, and I remain with hundreds of soffice.bin, unoconv, oosplash processes which waste ram and definitely crash the server.

Am I missing anything?

Is there a better way to invoke unoconv?

Should I run the unoconv server as a system service?

I'm using: LibreOffice 3.5, Unoconv 0.5, apache 2.2.22-13+deb7u4


I recommend the following:

  • use the latest version of unoconv (at least v0.7 when it is released, or the master branch from GitHub today)

  • use the most recent stable release of LibreOffice (recent releases use less memory, are generally much faster and crash less)

  • use the native LibreOffice python binary to run unoconv, eg. /opt/libreoffice4.4/program/python /usr/bin/unoconv -f pdf file.doc

  • hardcode the python path in the unoconv script shebang, so put on the first line #!/opt/libreoffice4.4/program/python rather than #!/usr/bin/env python. (Apache/PHP usually do not set PATH, so unoconv fails)

  • ensure that the user running unoconv has write access to its HOME directory

If you do the above, everything should work out fine. If LibreOffice still crashes, you should take this up with the upstream project. Also beware that LibreOffice cannot handle more than one connection/client at the same time, so ideally your PHP script should properly lock and/or queue requests. (Look at the flock system utility for this)

If you still have any issues, please report them to: http://github.com/dagwieers/unoconv/issues


According to the manual man unoconv can be run in listener mode and in client mode. In client mode, it will look for a running instance and will create one if could not find one.

You can try to run one instance in listener mode and change your command to connect to this instance. At least, you will save some resources by avoiding the need to run new instance every time.

Here is an example taken from the manual (run listener and do some conversions):

unoconv --listener &
unoconv -f pdf some-document.odt
unoconv -f doc other-document.odt
unoconv -f jpg some-image.png
unoconv -f xsl some-spreadsheet.csv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.