kipp Posted August 13, 2016 Share Posted August 13, 2016 Looking to make multiple calls to a script from within a loop....so ie, loop starts.... calls a separate php script (preferably via url location) loop continues (calling the same script above, but passes a variable to the script, essentially a count down variable) loop will stop once a set number of calls has been made Reason for this is I am trying to take a cron job script that keeps timing out and break it down into x number of calls to a similar script that will break down the time it takes for the script to run. Any helps/assistance is appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
benanamen Posted August 13, 2016 Share Posted August 13, 2016 What have you tried? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 13, 2016 Share Posted August 13, 2016 This hack is entirely unnecessary. If your script times out, then increase the time limit until it no longer times out: <?php // set the time limit in seconds (may also be -1 for no time limit at all) set_time_limit(600); // now do the work There may also be a chance to optimize the procedure and solve the problem altogether. For example, if the timeout is caused by long-running queries, this may be due to missing/inappropriate indexes. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 13, 2016 Share Posted August 13, 2016 Why call a script via url? Doesn't that add time to the process? Why not simply create a function that does what you want and call that from the main script inside your loop? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 13, 2016 Share Posted August 13, 2016 How would that solve any problem? A function call in the same process doesn't make the process shorter in any way. kipps' idea is to solve the timeout problem by splitting the long-running process into multiple independent short-lived processes. But as I already said in #3, timeout problems are solved by either optimizing the procedure (if possible) or increasing the time limit. There's no need for any hacks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.