Shell 磁盘空间

1. Shell 磁盘空间使用率

  • disk-space.sh
MAX=95
EMAIL=server@127.0.0.1
PART=sda1

USE=$(df -h | grep $PART | awk '{ print $5 }' | cut -d'%' -f1)
USE=`printf "%.0f\n" $USE`
if [ $USE -gt $MAX ]; then
   echo "Percent used: $USE" | mail -s "Running out of disk space" $EMAIL
else
   echo "all is well"
fi

执行:

$ bash disk-space.sh
all is well

更多阅读:

Copyright © ghostwritten 浙ICP备2020032454号 2022 all right reserved,powered by Gitbook该文件修订时间: 2022-06-22 16:52:21

results matching ""

    No results matching ""