I am running multiple shell_exec
, process.php
's run in the background
On the shell/ssh
, I execute the code like this: username [~/public_html/curl]# php index.php
Example....
index.php
<?php
shell_exec("php process.php > /dev/null 2>&1 &");
shell_exec("php process.php > /dev/null 2>&1 &");
shell_exec("php process.php > /dev/null 2>&1 &");
shell_exec("php process.php > /dev/null 2>&1 &");
?>
process.php
<?php
$section = rand(999,999999);
$z = 1;
print "STARTED ....
";
while($z <= 10) {
print "---------------------------------
";
print $section . ": " . $z . "
";
$z++;
sleep(2);
}
print "LOOP FINISH at " . time();
?>
when process.php
's is running, I am having two problems with this:
- I cant not see the output from
process.php
's (I need to know what they are doing) - I need to know which process is finish and which have started.
What the best way logging the output in real time? saving into text file? or how can it be done to mysql database (logs table)?