执行shell命令在后台运行php

I run a php script through shell using the following:

php script.php

How do I type this command in order to run it on the background and also log the output to a file?

I've tried

php script.php 2>&1 > out.log

But once I close putty, the script stopped. Thanks in advanced!

Add a & after the command.

Try call like this:

php script.php 2>&1 > out.log &

you can use nohup (no hang up)

  nohup php script.php 2>&1 > out.log

or you use cron or at to run your script in background