Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:14:11+00:00 2026-06-04T08:14:11+00:00

I need to start OpenOffice server in background (if it’s not instanciate) then do

  • 0

I need to start OpenOffice server in background (if it’s not instanciate) then do a file convertion with JODConverter.
The scenario is as follows :

  • The user inputs a *.html file by a form.
  • I get the file by the $_FILES variable in the PHP script corresponding to the form action
  • I run a bash script with shell_exec, and pass the temp path to it, to access the file ine my bash script, then do the convertion

This is the PHP code :

        $fichier = $_FILES['html_file'];
        if($fichier) {
            if(is_uploaded_file($fichier['tmp_name'])) {

                if(move_uploaded_file($fichier['tmp_name'],"/var/www/test/doc/".$fichier['name'])) {
                   $output = shell_exec("./converter {$fichier['name']}");
                   echo $output;
                } 
            } 
        } 

The script “converter” code :

#!/bin/bash
fichier=$1
pid=$$

echo RUNNING sOFFICE :

SERVICE=soffice
if P=$(pgrep $SERVICE)
then
    echo sOFFICE IS ALREADY RUNNING 
else
    echo sOFFICE WILL BE START WAIT 5s PLEASE 
    soffice --headless --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard &
    sleep 5
fi

echo CONVERSION START
java -jar ./jodconverter/lib/jodconverter-cli-2.2.2.jar ./$1 ./$1.odt
echo CONVERSION END

My problem is in the first part of the bash script, when I try to run the sOFFICE server in background, this command blocks the final execution of the script, even with the use of &.
I’ve tried to run this script by the terminal, and it works perfectly.
So I think, the problem come with the php execution of the bash script. Have an idea ?

EDIT :
Solution found thanks to Jim Rubenstein response :

redirect the standard out and standard error streams

:
Replace

soffice --headless --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard &

by

soffice --headless --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard > /dev/null 2> /dev/null &
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:14:12+00:00Added an answer on June 4, 2026 at 8:14 am

    This problem is typically solved with just adding a & at the end of the command; but it seems like you also need to redirect the standard out and standard error streams. I found responses to the same question on stack overflow here:

    php execute a background process

    Why this process is not running in background?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need start off with code because I am not sure what terminology to
I need to start a Visual Basic script file by using WMI in a
I need to start a program every time the user logs in, but I
I need to start H2 database in server mode from my application. Having tried
I am writing a bash file. I need to start apachectl from my bash
So many buzzwords. Not sure if I need to start playing BS Bingo or
I need to start messing with a vb.net(vs2008) project file and I'd like a
I need to start a new project with Django, but I'm not sure what
I need do start the derby server from my java application using org.apache.derby.drda.NetworkServerControl class.
I need to start and stop SQL Server from the command line. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.