shell相关脚本

清除日志脚本

#!/斌/庆典
  #
  清除日志
  脚本,版本2 LOG_DIR = /无功/日志ROOT_UID = 0#$ UID为0的时候,用户才具有根用户的权限
#要使用根用户来运行。
  如果[“$ UID “-ne”$ ROOT_UID“]

     回显”必须是root才能运行此脚本“。
     退出1
  fi  
cd $ LOG_DIR || {
    echo“无法更改为必要的目录。”>&2
    退出1
  }
  cat / dev / null> messages && echo“清理日志”.exit
  0
  #退出之前返回0表示成功。返回1表示失败。

#打印日志

sleep 1 
echo 123 >> /server/log/oldboy.log

# 压缩备份

cd /var/www/&&\
tar zcf /data/www_$(date +%F).tar.gz ./html

#只保存7天的数据
find /data/ -type f -name "*.tar.gz" -mtime +7|xargs rm -f

猜你喜欢

转载自blog.csdn.net/guoshaoliang789/article/details/84930699