Execute PHP script at the background

This post was written by Mahi-Bhat on January 1, 2013
Posted Under: PHP

Sometimes you may want to execute a PHP script at the background, then do not wait for completion of it and continue execution. This can be achieved by doing like this.

$shell_cmd = ‘/usr/bin/php sample.php &’;
pclose(popen($shell_cmd, ‘r’));

Note: The ‘&’ at the end of the command is mandatory.

Add a Comment

required, use real name
required, will not be published
optional, your blog address

Next Post: