How to start the execution of the file in the background on Ubuntu server?

Hello! On a Web server Ubuntu there is an app. It's also written a socket server in a file socket.php.
In the terminal I do manually
-> php socket.php
It can be launched.
Question: how can the application send command to server started in the background a file socket server?
And so it was possible to stop execution of the file via the app.
March 12th 20 at 08:39
2 answers
March 12th 20 at 08:41
Solution
Via crontab, service, daemon, nohup. Or as php socket.php &. A lot of options.
March 12th 20 at 08:43
Solution
In the script make the test of neglect.

As a variant - put its PID somewhere in a file at startup check - is there a PID file, does a process with this PID.

The script or via cron, or setsid/nohup

Find more questions by tags UbuntuLinux