In order to achieve the project picture resources upload, you can automatically compression, to speed up user access speed, found this technology inotify, about this technology specific introduction, here no longer verbose, Baidu a search has a lot of introduction.
Here is a single example to introduce the use of inotifywait
Vi/tmp/monitor_jpg.sh#!/bin/bashexport Lang=cinotifywait-mrq--event create,modify/data/jpg | While read eventdonewfile= ' ls-ltc/data/jpg | Grep-v Total | Head-n 1 | awk ' {print $9} ' convert-quality 25%/data/jpg/$newfile/data/conjpg/$newfiledone #wq Save exit # Permission change and put into background process chmod 700 Monitor_jjpg.shnohup/bin/bash/tmp/monitor_jpg.sh &
The purpose of the above script is to use the ImageMagick software to compress the image (approximately 1//data/jpg) when a picture is altered or created (depending on the file modification or creation time) when the image is monitored in the directory. 3 size) to the directory/data/conjpg/directory, save with the same name file.
When the site needs to refer to the picture, you can refer to/data/conjpg inside the picture, a lot of saving network bandwidth resources.
With regard to the INotify function, this is used only by the iceberg, reasonable use, also can achieve the project Automation release and rollback, but no longer manual participation in the publishing process
This article is from the "Letter" blog, please be sure to keep this source http://leon0long.blog.51cto.com/3011404/1633389
inotifywait actual operation