Skip to content

Instantly share code, notes, and snippets.

@jooray
Last active January 3, 2020 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jooray/c7583ebe6666bd948c18ce8ae07446fb to your computer and use it in GitHub Desktop.
Save jooray/c7583ebe6666bd948c18ce8ae07446fb to your computer and use it in GitHub Desktop.
optimize images
#!/bin/bash
dirs=( "/home/web1" "/home/web2" )
# run without "-mtime -3" for the first time, then put into cron
find "${dirs[@]}" -mtime -3 -name \*.png -exec optipng -preserve {} \;
find "${dirs[@]}" -mtime -3 \( -name \*.jpg -or -name \*.jpeg \) -exec jpegoptim {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment