Jump to content

Recommended Posts

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.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/301878-call-a-script-from-within-a-script/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.