<p>I have a PHP script that initialises an image gallery. It loops through all images, checks if they are thumbnailed and watermarks them.</p>

<p>My shared hosting account only lets me have 30 seconds of execution per script, as set in the php.ini settings. I can't change that.</p>

<p>What can I do to get round this? Currently I refresh the page after every 5 images, this prevents the script timing out, but the browser recognises that the script won't complete and gives an error. That's ok, but it's not really user friendly.</p>

<p>Any suggestions?</p>

three ideas:
you could offload this to a script that runs on the server (PHP CLI perhaps?) and have your current script check the progress (still running! check back later!).
if javascript is ok in your environment, perhaps you could make ajax calls to handle this as well. the first solution allows the user to keep wandering around the site though, not sure if that's an important consideration in your case.
you could get the PHP script to just do a certain batch (say 10 images at a time), then refresh the page with a progress report and go for 10 more, instead of an arbitrary time based refresh.