I have a php script that needs to run for quite some time.
What the script does:
What's in the apache error_log? Are you reaching the memory limit?
EDIT: Looks like you are reaching your memory limit. Do you have access to PHP.ini? If so, you can raise the memory_limit there. If not, try running curl or wget binaries using the exec or shell_exec functions, that way they run as separate processes, not using PHP's memory.