Solved

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

Posted on 2014-10-08
6
1,079 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 56

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 56

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress Only run code if on a certain page 11 35
Wordpress and Wufoo 1 39
MySQL-Design Help 12 44
Make an array show the subkey and put it in a query 2 29
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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 …

726 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