Solved

How to make PHP script execution wait for function to finish (and not trigger timeout)?

Posted on 2014-10-08
6
1,145 Views
Last Modified: 2014-10-08
Hello,

   how can I make PHP script wait for function to finish? - With "wait" I mean "not trigger timeout".

   I have site backup function that will zip entire site contents, and given amount of stuff to zip, it could take a while. I would like the script execution to wait patiently until the function has returned success (TRUE).

   I understand that I would need to also alter ZIP function, however I am not sure how to achieve any of the two.


Thanks!
0
Comment
Question by:mrmut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 250 total points
ID: 40367806
Have you had a look at the set_time_limit function?

http://php.net/manual/en/function.set-time-limit.php
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 40367833
Can you run your script on the command line and then come back and download the zip file?  Command line PHP programs don't have a timeout like the ones that run thru the web server.
0
 

Author Comment

by:mrmut
ID: 40367901
The site is hosted on RackSpace - just checking both with them!
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Closing Comment

by:mrmut
ID: 40367914
OK, so here is the deal on RackSpace. - The script time out is 15 MINUTES. Wow. However, they have load balancer that will cut client connection in 30 seconds if no response from the script.

So I guess it is a win/loose situation at the same time.

For the command line option, they have a set of stuff that is allowed to run, usually compress, decompress and stuff, via cron.

Thanks to both.
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 40367915
that will cut client connection in 30 seconds if no response from the script.
That is usually the default timeout for PHP - hence the recommendation to look at the set_time_limit function
0
 

Author Comment

by:mrmut
ID: 40367997
yes, yes, but their timeout is 900 sec, and the load balancer one is 30.

You have to understand that they sell CPU cycles, so they essentially profit from badly written code :-)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question