Jump to content

Call php files with their own run time limitation?


mr_zhang

Recommended Posts

Hi guys,

 

I'm currently developing a php program that has a very long run time.

 

I understand that I'm able to extend the run time.

 

However, my hosting provider (it's a shared hosting) has somehow turn the option off so that I'm not able to change the run time of a php script. They said it's a security issue and they won't budge.

 

So I have a question:

Is it possible to separate a long file so that they have each own run time but called in one go? I think include() is not the solution of this, although I'm not sure.

 

e.g.

I have a cron.php that needs 20 minutes to finished while my hosting only allowed 5 minutes for php run time. This long file could not be executed fully. Then, I would like to separate them into 5 files: cron1.php, cron2.php, cron3.php, cron4.php (each 1/4 of cron.php functions) and cron.php (calls those 4 files) so that they all finished. So, it's like I'm running 4 files with their own run time.

 

Is this situation possible? What is the solution?

 

Regards,

 

Link to comment
Share on other sites

Hi cooldude832,

 

Thanks for replying.

 

Well, it's somehow kindda spidering and indexing service like Search Engines. So the script will go to the internet and parse the content of pages of websites out there (my client owns them, don't worry about yours. For some reason, which I can't share here, they don't allow me to put any script on the existing sites to make the job easier and faster), then do it's own calculation based on those pages. I'm hoping that it could parse like millions of pages in one go.

 

I've also set the script to sleep() here and there to reduce the server load. I guess the sleep() won't affect the run time, will it?

 

Last time I checked it needs around 2 to 5 seconds to get one page (yes, one whole page) with file_get_contents() so it really needs a lot of time to complete.

 

So, I'm hoping that I can split the script into smaller chunks but still run them all in one go. Any suggestion?

 

Regards,

Link to comment
Share on other sites

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.