How to execute shell commands synchronously in PHP

后端 未结 5 922
小鲜肉
小鲜肉 2020-12-01 20:36

I need to run multiple scripts(5 scripts) via cmd, I want to make sure unless and until the first script finishes the second should not initiate. Thus after first script com

5条回答
  •  鱼传尺愫
    2020-12-01 21:28

    Check out the exec function syntax on php.net. You will see that exec does not run anything asynchronously by default.

    exec has two other parameters. The third one, return_var can give you a hint if the script ran successfully or any exception was fired. You can use that variable to check if you can run the succeeding scripts.

    Test it and let us know if it works for you.

提交回复
热议问题