This script sometimes hangs like 20mins until server PHP will show timeout error, and I don’t know how to set the time limit to kill it. set_time_limit doesn’t do anything. I have also read that exec is missing direct timeout command.
The problem is exec is a blocking command (it pauses execution until it finishes). You need to run the command slightly differently. On Linux, suffixing the command with & will actually put the output as the command after &. You will also need to redirect both stdout and stderr to /dev/null/. On windows you can use the start command:
Thank you, I like the Linux version, this works perfectly and really “much faster” than before(too fast maybe)… but I ran into other problems with this, because this script is part of a bigger script and it’s too fast. So sleep(5); after it will fix everything for now.
I have noticed that if using > /dev/null 2>/dev/null & on some bigger and slower sites the command fails, lack of time to load the site or something. Without the command > /dev/null 2>/dev/null & works the slower sites too, but then some sites may hang… I haven’t found a 100% working solution… are there any simple suggestions to make this simple script work?