0

I want to create a cronjob that runs jpegoptim and optipng everyday, to optimize images in my Magento install. I want to run this on my CentOS 7 install.

Therefore I edit /etc/crontab with the following:

0 13 * * * root lockrun -Q -L .lockjpegoptim -- find /media -iname *.jpg -exec jpegoptim --max=90 --strip-all --all-progressive -p {} \; > /dev/null
0 13 * * * root lockrun -Q -L .lockoptipng -- find /media -iname *.png -exec optipng -o7 -preserve {} \; > /dev/null

I want to be sure that this is correct, will this run right?
Is there a way to check if the cron run succesfully?

1

I have had similar requirements, and implemented this free extension on a site of mine instead: https://marketplace.magento.com/apptrian-apptrian-image-optimizer.html

I found it more convenient because it integrates with Magento cron, and you can set batch size etc. It also provides some visual on how far it is etc.

There were a few changes to the location of the binaries (optipng/jpegoptim), but after that it has worked great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.