Php recursive infinite page load

I have linux bash scripts that run continuously and request a php page. The php page does some magic, and after 500 ms, bash scripts again request the php page, and php does some magic. This is done day after day, but bash sometimes crashes, and that means I need to log in and run the scripts again. No, I'm looking for a solution that is fully managed by php.

I have done the following test (s) but will not work. FILE));

recursiveStopStart(true,$basepath); function recursiveStopStart($mayrun = true,$basepath){ if ($mayrun == true){ sleep(1); exec("C:\wamp\bin\php\php5.3.13\php.exe ".$basepath."/scripts/StopStart.php"); exec("C:\wamp\bin\php\php5.3.13\php.exe ".$basepath."/scripts/TestStopStart.php"); flush(); exit(); } } ?> 

StopStart.php are scripts that do magic. TestStopStartphp is the main php page that makes a recursive idea.

I am looking for a solution where I request 1 page, this page calls the magic page and calls itself to start all over again.

The second reason for switching to php is that I can make it platform independent (bash will not work on Windows ...).

Hope someone can help me.

+4
source share
2 answers

Create a PHP daemon. You will save so much headache.

http://pear.php.net/package/System_Daemon

System_Daemon is a PHP class that allows developers to create their own application daemon on Linux systems.

+2
source

Popular demonization libraries do not seem to work with cross OS. I am sure that this is due to the fact that services / processes are processed between * NIX and windows.

It looks like you will need to create a daemon on Linux using any number of popular libraries, System_Daemon, Supervisord,

And then create it on Windows http://www.akchauhan.com/create-windows-service-to-schedule-php-script-execution/ . This iscipe is for creating a service that runs your PHP script at intervals, such as cron.

+1
source

Source: https://habr.com/ru/post/1434689/


All Articles