Keeping a long running (forever) php CLI process running on Windows

665 views Asked by At

I have written a script that runs on a windows machine doing various tasks in a loop. It works great, except it exists, for no apparent reason every two hours.

I have used:

set_time_limit(0);

to ensure the script should keep running forever. The loop is actually caused by a class method calling itself - maybe there's a program counter limit or something?

I have written a bat file which automatically restarts the process if it dies, but I'd really rather it didn't die in the first place.

Does anyone have any suggestions?

1

There are 1 answers

2
John Hunt On BEST ANSWER

I'm not 100% certain, but I am fairly sure that I did indeed hit some kind of recursion limit in PHP. Using a while() loop the script has been running for at least 4 hours so far without a problem.

I'm not sure what the recursion limit is (or why an error wasn't displayed) but this has fixed the issue.