How to deal with long PHP scripts?

Example

Scenario:

I have a database with thousands of TV-shows which now and then gets updated by scraping info from http://thetvdb.com/ .

Problem:

The updates are done in batch jobs of 10-30 shows, which will most likely break the 30 seconds script limit on most servers.

Workarounds:

One option is to increase the script time limit another is to have the update-page refresh itself for every show it updates. Neither of these solutions seem proper.

Looking for:

A solution which calls the update script for each show that needs to updated. AJAX seems like the way to go, but is there a way for Yii to ease this task?

Thanks for reading.

Try running the script from a cron job to update your database.

Cheers, Wei.

Thank you for your reply Wei.

Is there no timelimit on PHP scripts if called from cronjobs?

My solution at the moment has been to add this code to the view file, which executes each show update separately.

        <script>';


    foreach ($showIdArray AS $id){


        echo CHtml::ajax(array('url' => "http://localhost/myproject/index.php?r=product/_getforeigndata/showid/$id", 'success' => 'function(html){document.getElementById("status").innerHTML += html}')) . "n";


    }


    echo


        '</script>';

Quote

Thank you for your reply Wei.

Is there no timelimit on PHP scripts if called from cronjobs?

My solution at the moment has been to add this code to the view file, which executes each show update separately.

        <script>';


    foreach ($showIdArray AS $id){


        echo CHtml::ajax(array('url' => "http://localhost/myproject/index.php?r=product/_getforeigndata/showid/$id", 'success' => 'function(html){document.getElementById("status").innerHTML += html}')) . "n";


    }


    echo


        '</script>';

You can read sth about php.ini and how to config it.