You can start a PHP script from the command line and keep it running as a background process:
nohup php myscript.php &
&puts the process in the background so it keeps running after you close the shell.nohupprevents the process from being killed when the parent shell session ends (it ignores theSIGHUPsignal).
Stopping it
A plain kill <pid> stops it — no special tooling required. For a script that needs to shut down cleanly (flush buffers, close connections), have it listen for SIGTERM with PCNTL
and exit gracefully instead of relying on SIGKILL.
When this is enough
This approach is simple on purpose. For anything beyond a single long-running background script — multiple workers, automatic restarts, log rotation — a process manager (such as Supervisor or systemd) is usually a better fit than rolling your own daemon management.
Andrew Dorokhov