Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nohup on windows, exec without waiting for finish

Tags:

php

windows

exec

Is there something like this for Windows?

exec("nohup /usr/bin/php -f sleep.php > /dev/null 2>&1 &");
like image 448
Marcin Avatar asked Nov 16 '10 18:11

Marcin


2 Answers

It's not that hard (albeit with some minor differences)... You just need to use the WScript.Shell COM object:

$shell = new COM("WScript.Shell");
$shell->run($command, 0, false);

That's it...

like image 156
ircmaxell Avatar answered Oct 16 '22 15:10

ircmaxell


By default, the Windows command start does not wait for the child process. You may want the /b switch to avoid creating a Command Prompt window.

exec("start /b c:\\php\\php.exe -f sleep.php");
like image 22
aschepler Avatar answered Oct 16 '22 15:10

aschepler