How to run a PHP script forever on a Linux VPS
Sometimes you just need to run your PHP script forever and i am not talking about Cron Jobs.
Cron Jobs are good and useful but it will trigger your script each minute, maximum.
I tried many things and this is the only one that really worked for me since i could not keep my PC running 24/7 with the SSH always open. I've tested this method and it ran for at least one week without any problems, with the CPU at 80% on average.
Open your SSH and type these two commands one after another:
screen watch -n 1 php /var/www/html/myscript.php &>/dev/null &
About these two commands you can read more here:
Update: A screenshot with the CPU usage for one week.