I have a PHP script on my server that, primarily, takes files from an upload and moves them into place. It usually works fine, but occasionally, the script won't start for 20-30 minutes. The entire uploaded files (roughly 0.5 MB) will be sitting in the tmp folder during the wait, so it seems like the data transfer is complete. Here is an excerpt from the Apache access log indicating a POST to the script (from an Android app)...
[29/Nov/2011:11:21:55 -0500] "POST /submit.php HTTP/1.1" 200 288 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"
However, this entry doesn't show up in the access log until 11:43 or so, surrounded by other page requests from 11:43:42 and 12:00:02. This leads me to believe the entry doesn't get written until the script executes, but it is written with the time of submission. Here's the error log, where I'm writing events from the script...
[Tue Nov 29 11:43:19 2011] Script started: Nov 29, 2011 11:43:19
[Tue Nov 29 11:43:19 2011] Audio file provided
[Tue Nov 29 11:43:19 2011] Timestamp provided
[Tue Nov 29 11:43:19 2011] Defaults set
[Tue Nov 29 11:43:19 2011] Connected to database
[Tue Nov 29 11:43:19 2011] Database selected
[Tue Nov 29 11:43:19 2011] Query successful
[Tue Nov 29 11:43:19 2011] 551: ID set
[Tue Nov 29 11:43:19 2011] 551: Audio file moved
[Tue Nov 29 11:43:19 2011] 551: Algorithm succeeded
[Tue Nov 29 11:43:19 2011] 551: Algorithm query succeeded
[Tue Nov 29 11:43:19 2011] 551: Photo type identified
[Tue Nov 29 11:43:20 2011] 551: Photo and thumbnail saved
[Tue Nov 29 11:43:20 2011] 551: Cache cleared
[Tue Nov 29 11:43:20 2011] Script finished: Nov 29, 2011 11:43:20
Any idea what would cause a PHP script to not execute for so long, or what kind of logging I should put in place to find out? The server is running Ubuntu 10.04, Apache 2.2.14, and PHP 5.3.2.