Batch processing images w/ CRON
Posted by: Cobra
Posted on: 2008-06-04 19:33:00
I just completed a PHP script that I will use to manipulate images uploaded to my server. I'm not sure how resource intensive it actually is, but it generally takes between 5 and 15 seconds per image. I feel it is best not to run the script on the images right when they are uploaded. Instead, I want to run the script in the wee hours of the night when there is less stress on the system. I have a database set up that records which images have been processed and which need to be processed.
The question is - how to go about this?
From looking at the panel, the most frequent CRON job interval is every 10 minutes. Running the script on one image every 10 minutes isn't an option. The list of unprocessed images would grow and grow. I've thought of a two options:
1) Run the script on images in a do/while loop until a certain amount of time has passed.
2) Use a while loop to run the script until a certain number of images are completed.
Any others? I think the problem with the above is that the script would likely go over the 30 second limit.
-Dave