Batch processing images w/ CRON

software development


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.



It might be faster to batch convert the images on your machine and then upload them via sftp. If you are using OS X, Linux, or Cygwin it would be easy to have a bash script convert all images and then scp over. If you are using windows you could use a batch script and WinSCP:


Thanks for the quick response. I’m sure it would be faster to do it the way you suggested but I don’t know much about batch files. Would I have to convert my PHP script to batch? I didn’t think thats possible. Or does the batch file run the PHP script so the work is done on the client side? Again, I didn’t think thats possible.
As you can see, I have no idea how to go about using batch files or WinSCP. Could you elaborate?


there is also a version of Gimp for windows that can be used for batch conversions of images if you don’t own a program like Photoshop.

You can also install php on windows if you want to use your php script:


I had no idea you could run php on windows. Tried the download off, but couldn’t figure it out. Instead, I got WampServer ( which is working great for me so far.