I’ve been researching how to best write a long running PHP script executed on the command-line, and whilst there are Linux commands you can use to daemonise a command, these can also be written into a php script as well.
The easiest way to daemonise a command on a posix system is to run:
nohup command < /dev/null > /dev/null 2>&1 &