I'm using Ubuntu Linux and running my website on an Apache server. Through PHP I'm trying to run an executable that is in a specific directory, but I want this process to run in the background and in some window for it to be maintained.
I've tried several command exec
system
and shell_exec
and at the moment it's like this, what am I doing wrong?
$startOT = "";
if ( isset($_GET['Server']) ) {
$startOT = trim($_GET['Server']);
}
if ($startOT == "Start") {
if (substr_count(shell_exec('sudo pstree'),'tfs') >= 1) {
echo 'Server is executing';
}
else {
$startCommand = 'cd /var/www/html/datapacks/baiak860/ && sudo screen && sudo ./tfs';
$out = shell_exec($startCommand);
echo $out;
echo "Server has been started!";
}
}