pyronaur
pyronaur

Reputation: 3545

Heavy CRON Tasks

I have to run a pretty heavy task on PHP once a week (script that curls to various locations (websites, API's), gathers, sorts data and inserts it into a db). The whole script takes about 10 to 15 mintues to run on my mac (localhost) - guessing it'll run a bit faster on a server. Nevertheless - I'm currently looping through with AJAX, so when each task is finished, next one is launched. Now I need to run it weekly, automatically. So I think I can't do it with AJAX Anymore.

Do I have to just set the php.ini to let a script run for 30 mintues or there is a better way to do it ?

Upvotes: 0

Views: 474

Answers (2)

Lars
Lars

Reputation: 5799

The maximum execution time of the PHP script is determined by the amount of time in which no output has been generated. So writing data into STDOUT (e.g. to a logfile) will keep the script running.

However, if you're running the script from command line, the max-execution-time will be defaulted to zero anyway and as already suggested, I'd start the script with a cronjob instead of an AJAX-Request or similar methods. I actually do that for most of my php-scripts performing administrative tasks like synchronizing data across several databases or similar purposes.

Upvotes: 1

Marc B
Marc B

Reputation: 360662

php.ini has nothing to do with scheduling jobs. It's simply definining PHP's startup settings. What you want is a cron job, as your title says.

For OSX cron setup, see http://hintsforums.macworld.com/showthread.php?s=&threadid=39005

Upvotes: 1

Related Questions