I need to run several PHP scripts (they parse and retrieve some data through OAuth) in the right sequence, ONE AFTER ANOTHER, waiting for the previous to be completed (script2 needs data to be parsed after script1 and so on...).
For example:
script1.php -> COMPLETED -> script2-php -> COMPLETED -> script3.php -> ....
I'm calling scripts from mainscript.php
with the following code:
<?php
echo '<br /><br />SCRIPT 1<br /><br /> ';
include ("script1.php");
set_time_limit(0);
$seconds = 5; // HERE I PUT 5 SECONDS BECAUSE I THINK ITS THE RIGHT TIME TO RUN PARSING
sleep($seconds);
echo '<br /><br />SCRIPT 2<br /><br />';
include ("script2.php");
set_time_limit(0);
$seconds = 5; // HERE I PUT 5 SECONDS BECAUSE I THINK ITS THE RIGHT TIME TO RUN PARSING
sleep($seconds);
echo '<br /><br />SCRIPT 3<br /><br /> ';
include ("script3.php");
set_time_limit(0);
$seconds = 5; // HERE I PUT 5 SECONDS BECAUSE I THINK ITS THE RIGHT TIME TO RUN PARSING
sleep($seconds);
echo '<br /><br />SCRIPT 4<br /><br /> ';
include ("script4.php");
?>
So my question is: Does it make sense putting the set_time_limit
and sleep into mainscript.php
, or the INCLUDE
function calls every script in the right sequence, in succession? Can you provide a solution, a suggestion?