Optimize Images for Faster Loading - Ubuntu
#1
Optimize Images for Faster Loading - Ubuntu
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
Reply
#2
RE: Optimize Images for Faster Loading - Ubuntu
This cron will use a lot of CPU so better if you downgrade priority using NICE

http://askubuntu.com/questions/48708/cha...ng-process
No support using PM (Auto adding to IGNORE list!), use the forum. 
How to ask

200$ free to start your VPS 60 days credit
Reply
#3
RE: Optimize Images for Faster Loading - Ubuntu
this is just for zadmin?

also is there a method to manually start or say on a specific time and date?
Reply
#4
RE: Optimize Images for Faster Loading - Ubuntu
(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/
Reply
#5
RE: Optimize Images for Faster Loading - Ubuntu
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Upgrade to Ubuntu 16.04 from 14.04 HogensHero 8 33 ,909 07-18-2020, 03:13 AM
Last Post: dycott78
Ubuntu: How to Enable tls/ssl in proftpd Diablo925 2 14 ,249 04-21-2020, 03:35 AM
Last Post: iraqiboy90
Ubuntu 18.04 or 20.04 Kangarooo 1 8 ,031 03-20-2020, 11:39 AM
Last Post: Jettaman

Forum Jump:


Users browsing this thread: 1 Guest(s)