zoukankan      html  css  js  c++  java
  • 监测linux一些重要文件md5值脚本

    今天写了个小小的监测linux重要文件md5值的脚本,
    为了安全最好在安装好系统之后部署

    其实网上有开源软件 监测文件是否被修改


    #!/bin/bash
    #crontab everyday
    FILENAME=`hostname`_MD5_`date +%Y%m%d%H%M`.txt
    FILETEMP=`hostname`_MD5_`date -d yesterday  +%Y%m%d%H%M`.txt
    logpath=/data/`date +%Y%m%d`
    if [ ! -d $logpath ]; then
       mkdir $logpath
       chmod ugo+w $logpath
    fi
    cd $logpath


    find /bin -type f |sort |xargs md5sum >$FILENAME.bin
    find /sbin -type f |sort |xargs md5sum >$FILENAME.sbin
    find /usr/bin -type f |sort |xargs md5sum >$FILENAME.ubin
    find /usr/sbin -type f |sort |xargs md5sum >$FILENAME.usbin
    find /etc -type f |sort |xargs md5sum >$FILENAME.etc

    ####
    md5sum  -c $FILETEMP.bin  |grep -v OK >>$FILENAME
    md5sum  -c $FILETEMP.sbin |grep -v OK >>$FILENAME
    md5sum  -c $FILETEMP.ubin |grep -v OK >>$FILENAME
    md5sum  -c $FILETEMP.usbin|grep -v OK >>$FILENAME
    md5sum  -c $FILETEMP.etc  |grep -v OK >>$FILENAME

    cd ..
    find . -mtime +7 -name '*_MD5_*' -exec rm -f {} \;

    =============================
  • 相关阅读:
    Nginx日志管理
    Nginx负载均衡
    Nginx 缓存
    Nginx代理服务器
    Nginx搭建 Web服务
    Nginx HTTP模块
    洛谷P1012拼数
    洛谷 P1876 开灯
    洛谷P2084 进制转化
    关于typedef的用法
  • 原文地址:https://www.cnblogs.com/4admin2root/p/2931902.html
Copyright © 2011-2022 走看看