0

I am trying to run this php script in my linux based server.

$today      = strtotime("today");
$tommorow   = date("Y-m-d", strtotime("+1day",$today));
$today      = date("Y-m-d");

//Endless loop because the data here updates around the clock 
while(1){

    while (time() <= strtotime("$tommorw 8:00PM")){

            sleep(30);
            flush();
        }

    }//end 24 h loop
    //save the file as a date file and delete it's content


    //move on to the next day   
    $today      = strtotime("today");
    $tommorow   = date("Y-m-d", strtotime("+1day",$today)); 

}//end of endless loop 

and it workes fine if I run it from a simple browser (ofcourse it stops working when I close it).

I am trying to run it through a perl script

chdir("mydir");
exec('indices.php');  #tryed also system("php indices.php");

and run the perl script like so

./PROMadadim.pl >> ./PROMadadim.log &

but it doesn't work when I am trying to run it from the server.

3
  • its called a Daemon, google "php Daemon" Commented Jun 21, 2012 at 21:56
  • 3
    Why do you say "it doesn't work"? What specifically occurs? Is it running but functions incorrectly? Does it not run at all (ps -A shows nothing)? Commented Jun 21, 2012 at 21:59
  • Setup a cron job. Having infinite loop is not nearly remotely adviced. Commented Jun 21, 2012 at 22:16

1 Answer 1

2

By looking at the code your probably better to setup a CRON job. If your server doesn't support CRON then you could try adding...

set_time_limit(0);

or try adding -q to the php command like so:

php -q /home/user/example.php
Sign up to request clarification or add additional context in comments.

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.