#!/bin/bash#check_file_md5 find/application/nginx/html/test1/-type F | Xargs md5sum >/tmp/web_md5_f.txt#check_file_num tree-i/application/nginx/html/test1 | Grep-v "^$" >>/tmp/web_md5_num.txt.defaultmd5= '/usr/bin/md5sum-c/tmp/web_md5_f.txt | Grep-v "OK" | Wc-l ' tree= ' tree-i/application/nginx/html/test1 | Grep-v "^$" >/tmp/web_md5_num.txt ' If ["$MD 5"-ne 0];then Echo "at $ (date +%f)/application/nginx/html/test1 h As been changed! Make sure! " else echo "Everything is ok!" Fidiff/tmp/web_md5_num.txt/tmp/web_md5_num.txt.default
The principle of implementation is
1. Monitor the MD5 value of the file before and after the same, if not the same md5sum error when comparing
2. Output to the specified file via the tree command, using diff to compare the generated content of the two before and after, if there are more or less files, will prompt
Knowledge Points:
MD5SUM-C: MD5 value can be achieved before and after the comparison, if the comparison fails, will prompt failed
Tree-i: Remove the tree structure and display it directly as a column
This article is from the "burning Years of Passion" blog, please be sure to keep this source http://liuzhengwei521.blog.51cto.com/4855442/1773018
Use the shell to monitor if the files under the site Directory have been modified