initial-script.php
exec("start /B php file.php >> log-file.log");
file.php
<?php die(phpversion()); ?>
log-file.log
5.5.11
I have 3 php installations in Program Files (x86):
I'm looking to force the exec to use v5.4, is this possible?
I've tried different variations to the c:/Program Files (x86)/PHP/v5.4/php.exe file to no avail, usually the script just hangs. One final note, I'm on a Windows 2008 server so nix commands are futile... :/
As Dagon pointed out, the path needs to be defined. However, in Windows, you need to enclose paths with spaces using double quotes. I was also not able to run the script with start /B as originally posted. I'm also using popen now. Here is the working code:
pclose(popen('"C:\/Program Files (x86)\/PHP\/v5.4\/php" file.php var1 var2 >> log-file.log 2>&1 &', "r"));
You'll also see that I've escaped the slashes, hence the \\/
.
Thanks for your help, SO.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.