Stephan Kristyn Stephan Kristyn - 11 months ago 84
Git Question

Git Hook PHP Script: No Output

I have this Script



$output1 = shell_exec('git pull');
$output2 = shell_exec('pkill java');
$output3 = shell_exec('mvn package');
$output4 = shell_exec('java -jar ./target/compute-0.0.1-SNAPSHOT.jar');

echo "<pre>$output1</pre>";
echo "<pre>$output2</pre>";
echo "<pre>$output3</pre>";
echo "<pre>$output4</pre>";


When executing in shell, I am not seeing any output in order to verify that it is running. I am not sure at all it is working. Is there a better way to do this automation script?

Answer Source

How to send of the java command with shell_exec and leave it running in background (Is & possible with shell exec)?



 echo "Do something"
 /bin/sh -c 'sleep 10' >> /dev/null 2>&1 &

 exit 0
  • /dev/null can be also a path to an logfile
  • All pathes here and in phpscript should be absolute, like: /path/tomy/

Here the test.php doesnt wait 10 seconds for the subcall.

Hope that helps a little ;)