我有一个在Docker容器内运行的备份脚本,我希望它在磁盘使用率低时向我发送电子邮件.
原文链接:https://www.f2er.com/ubuntu/348016.html这是脚本:
#!/bin/bash CURRENT=$(df /data | grep / | awk '{ print $5}' | sed 's/%//g') THRESHOLD=90 echo "$CURRENT" if [ "$CURRENT" -gt "$THRESHOLD" ] ; then echo "Low Disk Space Alert: ${CURRENT}% used" mail -s 'Disk Space Alert' olalonde@gmail.com << EOF Backup server remaining free space is critically low. Used: $CURRENT% EOF fi
FROM ubuntu:latest MAINTAINER olalonde@gmail.com ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get install -y postfix && \ apt-get install -y mailutils && \ apt-get clean ADD rootfs / CMD /disk-alert.sh