Start one script after another consecutively

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Start one script after another consecutively

Post by alex.barylski »

But not simultaneously...

Currently I have a proxy script which does something like:

Code: Select all

shell_exec('myscript.php');
sleep(10);
shell_exec('myscript2.php')
My fear is that occassionally myscript2.php *might* start before myscript.php finishes which isn't always bad but it could be a PITA and cause weird bugs.

Ideally when the proxy script runs it would execute the first script and only once it's finished and returned execution back to the proxy would it continue with executing the second script.

Reading the docs on shell and process control it sounds like passthru might do the trick of ensuring the scripts execute in proper order??? Anyone care to confirm? Ideally I find a cross platform solution so no crazy process manipulation please.

Cheers :)
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

Re: Start one script after another consecutively

Post by panic! »

couldn't you just append one script to another?
Post Reply