Php script running as scheduled task hangs - help!

Posted by Ali on Stack Overflow See other posts from Stack Overflow or by Ali
Published on 2009-06-24T08:23:02Z Indexed on 2010/05/03 7:08 UTC
Read the original article Hit count: 268

Filed under:
|
|

Hi guys, I've built a php script that runs from the command line. It opens a connection into a pop3 email account and downloads all the emails and writes them to a database, and deletes them once downloaded. I have this script being called from the commandline by a bat file. in turn I have created a scheduled task which invokes the bat file every 5 minutes. The thing is that I have set the time out to zero for the fact that at times there could be emails with large attachments and the script actually downloads the attachments and stores them as raw files offline and the no timeout is so that the script doesnt die out during downloading.

I've found that the program hangs sometimes and its a bit annoying at that - it always hangs are one point i.e. when negotiating the connection and getting connected to the mail server. And because the timeout is set to zero it seems to stay stuck up in taht position. And because of that the task is not run as its technically hung up.

I want that the program should not timeout when downloading emails - however at the points where it is negotiating a connection or trying to connect to the mailserver there should be a timeout only at that point itself and not the rest of the program execution.

How do I do this :(

© Stack Overflow or respective owner

Related posts about php

Related posts about timeout