How to keep a persistent PHP script running?

apache, daemon, php, sockets

Solution

myscript.php &

This will run the scriptin the background

you can check it with

ps aux | grep myscript.php

As Patrick has mentioned in the comments below, there is no maximum execution time for PHP scripts run from command line. `myscript.php` will run indefinitely.

Problem

I have a PHP script that listens for incoming socket requests, etc. I need this script to be continually running (it runs within an infinite loop) on the server. How can I initiate and manage this process? I tried just starting it up through SSH/putty but as soon as the SSH connection times out the script dies.

Original source

Related problems