Quantcast
Channel: How to execute shell commands synchronously in PHP - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Answer by vinit agrawal for How to execute shell commands synchronously in PHP

$
0
0

Both exec and system wait for the script to execute unless you don't fork.

Check.php

<?php    echo "here ".__LINE__."\n";    exec ("php phpscript1.php");    echo "here ".__LINE__."\n";    system("php phpscript2.php");    echo "here ".__LINE__."\n";?>

phpscript1.php

<?phpecho "=================phpscript1.php\n";sleep(5);?>

phpscript2.php

<?php    echo "=================phpscript2.php\n";    sleep(5);    ?>

Check.php execute script1 for 5 seconds then display next line number and then execute script2 by printing the next line.


Viewing all articles
Browse latest Browse all 6

Trending Articles