0

I have this sample code called main.php:

<?php
shell_exec('C:\wamp\bin\php\php5.4.3\php.exe a.php');
shell_exec('C:\wamp\bin\php\php5.4.3\php.exe b.php');
?>

when execute this script after executing first shell_exec it staying until finishing first shell_exec and then run second.

but I want that script dont stay for finishing first shell_exec and its output and runs second.

now how can I do this?

I have several scripts and I need to run them Simultaneously by a main script and control them by it. but I dont know that how to run my scripts Simultaneously from inside of this main script?

update1: I cant run a.php and b.php by cron jobs because their finishing time is unknown. maybe a.php finished after 1 hour or 10 minutes and b.php as same as a.php too.

update2: I founded a solution in this page:

Is there a way to use shell_exec without waiting for the command to complete?

5
  • what is the use-case? Possible solutions would include ajax or for example scheduled jobs if it's just something that needs to run periodically. Commented Jul 23, 2013 at 1:14
  • I dont run these scripts by browser. these scripts must run in background Commented Jul 23, 2013 at 1:25
  • If you are looking for a shell script, check this question: stackoverflow.com/questions/672719/… Commented Jul 23, 2013 at 1:28
  • @jeroen I dont understand them. I only want a simple way to run an cmd command from inside of a php script and dont stay for its output and execute rest of my script codes :( Commented Jul 23, 2013 at 1:40
  • Duplicate of stackoverflow.com/questions/7657846/… . Commented Jul 23, 2013 at 8:21

1 Answer 1

1

If i understand you wish to run a background process on a Windows box.Suggest try this...

<?php
    shell_exec('start /b C:\wamp\bin\php\php5.4.3\php.exe a.php');
    shell_exec('start /b C:\wamp\bin\php\php5.4.3\php.exe b.php');
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.