Solved

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

Posted on 2014-10-08
6
907 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
  • 3
  • 2
6 Comments
 
LVL 51

Accepted Solution

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

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

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
Comment Utility
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
Comment Utility
The site is hosted on RackSpace - just checking both with them!
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Closing Comment

by:mrmut
Comment Utility
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 51

Expert Comment

by:Julian Hansen
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now