PHP - Program redirects to itself but this does not work when launched by CRON

40 views Asked by At

I have a program that calls itself iteratively.

redirect($_SERVER["PHP_SELF"]);

function redirect($url,$seconds=0) { 
$html="<html><head><meta http-equiv='refresh' content='$seconds; URL=$url'></head></html>";
echo $html;
exit();
}

If I start it from the URL it works great, but if I launch it with CRON it does not work.

Is there another way to make a program call itself that will work with CRON?

1

There are 1 answers

0
CreeperMaxCZ On

Is there another way to make a program call itself that will work with CRON?

Yes, there is. You can use exec in your code instead of the redirect:

exec("php script.php");

or

exec("/usr/bin/php script.php");