[email protected] PART=sda1 USE=$ df h grep $PART awk '{ print $5 }' cut d'%' f1 USE= printf '%.0f...">

当前位置:网站首页>Shell disk space usage

Shell disk space usage

2022-06-09 01:20:00 ghostwritten

Shell Disk space usage

  • disk-space.sh
MAX=95
EMAIL=[email protected]
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

perform :

$ bash disk-space.sh
all is well

Read more :

原网站

版权声明
本文为[ghostwritten]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090117488238.html