Solved

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

Posted on 2014-10-08
6
988 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 54

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 54

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 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