tags:

views:

35

answers:

2

Basically I have an issue. I am posting to my users facebook statuses using a cron job, but when i run the cron from the browser I get an error after about 30 seconds. I have edited the .ini file to allow max execution time but it dont seem to work.

It updates the statuses of the first 700ish users but after that it stops.

Can I run it from the terminal or is there anything I can check/do to get around this?

A: 

Make sure that you'll see errors by doing:

error_reporting(E_ALL);
ini_set('display_errors',1);

at the top of your script.

You could be running into a max_execution_time ceiling, or you could be running out of memory, etc. Error messages will help with determining that.

As Frank Farmer implies in his comment, you can use set_time_limit(0); in your script to allow it to run indefinitely.

If you're having memory limit issues, you can up time memory limit in your script (ini_set('memory_limit',...);) -- but you should really consider fixing your code so it doesn't keep consuming memory.

timdev
+2  A: 

When running PHP scripts from the command line the default max execution time is 0 - that is, unlimited. From an HTTP context there's other settings that can shutdown your script, including the Apache Timeout directive. This is definitely a job I'd run through the PHP CLI.

I would enable error logging which would describe what limits your script is running into. There's a lot of possibilities - you may be hitting the memory limit, the execution time may be too low, the Facebook API may be rate-limiting your requests, etc.

pygorex1