SHELL-限制mysql数据库文件大小脚本

时间:2022-09-14 17:40:40
#!/bin/sh #du -h /www/db/mysqldb/data/ >DB_CONTROL_NUM.txt #du -h /www/db/mysqldb/data/ |grep M | awk '{print $2}' >DB_CONTROL_NUM.txt #du -s /www/db/mysqldb/data/* | awk '{print $2}' >DB_CONTROL_NUM.txt cd /www/db/mysqldb/data/ ls | sed "s:^:`pwd`/:" >/usr/local/primahms/shell/DB_CONTROL_NUM.txt  ------提取目录文件 cd /usr/local/primahms/shell for i in $(cat DB_CONTROL_NUM.txt ) do  #echo $num;  num=`du -s $i | awk '{print $1}'`  #num_T= $num - 50;  #echo $num_T;  if echo 100000-$num|bc|grep -E '^-' >>db_log.txt      ------------大于110M的限制  then  #echo $num;  echo $i >>db_log.txt;  chmod 500 $i;  fi done
注:ls | sed "s:^:`pwd`/:" 列出文件绝对路径

本文出自 “守候者” 博客,请务必保留此出处http://shouhouzhe.blog.51cto.com/2351955/1376892