Use the shell to monitor if the files under the site Directory have been modified

Source: Internet
Author: User

#!/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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.