Sentora Support Forums

Full Version: Optimize Images for Faster Loading - Ubuntu
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
To optimize all the images in the public_html folder once a month. Run this:

Code:
apt-get install jpegoptim optipng

Code:
nano /etc/cron.monthly/optimgs

Code:
#!/bin/bash cd /var/sentora/hostdata/zadmin/public_html find -iregex '.*\.\(png\)$' -print0 | xargs -0 optipng -o7 -preserve find -iregex '.*\.\(jpg\|jpeg\)$' -print0 | xargs -0 jpegoptim --max=90 --strip-all –all-progressive --preserve --totals find -iregex '.*\.\(jpg\|png\|jpeg\)$' -exec chmod 644 {} \; find -iregex '.*\.\(jpg\|png\|jpeg\)$' -exec chown www-data:www-data {} \; exit 0

F3 will save the file and Ctrl+X will exit nano.

Code:
sudo chmod +x '/etc/cron.monthly/optimgs' sudo chmod 755 '/etc/cron.monthly/optimgs'

A bit of a warning. OptiPNG is very slow. May take a few hours to complete if you have a large amount of .pngs
This cron will use a lot of CPU so better if you downgrade priority using NICE

http://askubuntu.com/questions/48708/cha...ng-process
this is just for zadmin?

also is there a method to manually start or say on a specific time and date?
(03-13-2016, 11:33 AM)warmax356 Wrote: [ -> ]this is just for zadmin?

This is for Sentora.

(03-13-2016, 11:33 AM)warmax356 Wrote: [ -> ]also is there a method to manually start or say on a specific time and date?

It's just a cron job. You can create a cron job to run when ever you like.
http://www.cyberciti.biz/faq/how-do-i-ad...unix-oses/
(03-04-2016, 10:46 PM)Me.B Wrote: [ -> ]This cron will use a lot of CPU so better if you downgrade priority using NICE

http://askubuntu.com/questions/48708/cha...ng-process

Been running this for awhile now. It really doesn't use that much CPU. Did a load test to see how much it effected the server, and it doesn't slow down the site at all.