views:

34

answers:

0

Here's my issue: I have a long running script which is ran via cron job twice a day.

The script will: 1) Select all users in the database 2) For each user, fetch data from another website based on the user's name. This takes 30-40 seconds, 2) Update that data in the database

The problem is, the cron job is returning Internal Server Error 500. So, after writing this, I guess I have 2 questions.

1) Can someone give me some tips on optimizing long scripts with PHP? I'm on shared hosting at the moment, but they are very loose on rules and limitations.

2) Why is my script returning a 500 Internal Server Error? When I run the script via browser, it runs fine.

Thanks in advance, appreciate any answers :)

More info on 500 error - this is what I get in my mail after the cron job runs.

Resolving X.com... 11.11.11.111 Connecting to X.com|11.11.11.111|:80... connected. HTTP request sent, awaiting response... 500 Internal Server Error 12:10:03 ERROR 500: Internal Server Error.

Not sure why this happens, as I can run the script perfectly fine in the browser and it will work. But whenever the cron tries to take over, this happens.