Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1514
  • Last Modified:

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

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
mrmut
Asked:
mrmut
  • 3
  • 2
2 Solutions
 
Julian HansenCommented:
Have you had a look at the set_time_limit function?

http://php.net/manual/en/function.set-time-limit.php
0
 
Dave BaldwinFixer of ProblemsCommented:
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
 
mrmutAuthor Commented:
The site is hosted on RackSpace - just checking both with them!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
mrmutAuthor Commented:
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
 
Julian HansenCommented:
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
 
mrmutAuthor Commented:
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now