4

I have a linux bash scripts that runs continuously and request a php page. The php page does some magic and after 500ms the bash scripts request the php page again and php does some magic. This runs day in day out, but sometimes the bash crashes and that means that i needs to login to the machine and run the scripts again. No i'm looking for a solution that is totaly php driven.

I made the following test(s), but the won't 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 is the scripts that does the magic. TestStopStartphp is the main php page which make the recursive idea.

I'm looking for a solution on which i request 1 page, that page calls the magic page and calls itself to run everything all over again.

A second reason to move to php is that i can make it platform independent (bash wont run on windows...).

Hope somebody could help me.

0

2 Answers 2

2

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 daemon applications on Linux systems

Sign up to request clarification or add additional context in comments.

2 Comments

I'm familiar with System_Daemon and would be a good option for linux based options. But i want a platform independent options and System_Daemon won't run on Windows.
Sorry, can't help you with windows. Good luck!
1

The popular daemonizing libraries don't seem to work cross OS. I'm sure this is due to the vastly different way services/processes are handled between *NIX and windows.

It looks like you will have to create a daemon in linux using any number of the popular libraries, System_Daemon, Supervisord,

And then create one in Windows http://www.akchauhan.com/create-windows-service-to-schedule-php-script-execution/. This is arecipe to create a service that executes your php script on interval like cron.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.