Run a PHP script on the background in Windows

Use this:

pclose( popen( 'start /b ' . $path_to_php_exe . ' -f ' . $script_filename . ' -- ' . $args, 'r' ) );

Now something important to note: any output from your script will prevent the above from working, including error messages. The PHP process will hang on the background and waits for you to fread() the output. Also double-check the quotes and escaping in your filenames and arguments!

Advertisements
Tagged ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: