I run a php trading script every 20 seconds with AJAX from a web app. 20 seconds because its time execution differs from 6 to 18 seconds. I can't find a reliable way to improve this by running the script on the server side, and restart it after he finished last execution (as the more the script runs, the more he wins). I also want to be able to play/pause its execution from the web app ?
What would be the best way, which could run for weeks without being timeouted like a PHP do-while or a JS setInterval ?
Thanks for your help