Php – run php script in the background

PHPputtyscriptingshell

is there a way to launch a php script and let it run on the server until it finishes?

I use this

php5-cgi /var/www/script.php -q &

connecting via putty. When I close it (the session) the script stops! Why does it run dependent on the session?

Best Answer

Try nohup and disown:

nohup php5-cgi /var/www/script.php -q &
disown