RHCE---作业3

一.判断磁盘空间

1、判断当前磁盘剩余空间是否有20G,如果小于20G,则将报警邮件发送给管理员,每天检查一次磁盘剩余空间。

复制代码
# 为了方便测式使用每分钟发送一封邮件,若想要每天定时检查则需要将前两个*改为0 0 
[root@timeserver ~]# crontab -e
* * * * * (($(df -m | grep -w "/" | tr -s " " | cut -d " " -f4)<20408)) && echo "内存空间不足" | mail -s "内存空间不足" 3291614481@qq.com

当前时间

发送邮件时间

复制代码
[root@timeserver ~]# vim test2.sh
x=`systemctl status httpd | grep Active | tr -s " " | cut -d " " -f4`
if (($x==(runing) ))
then
        echo "httpd is already running "
else
        echo " httpd not started ,waiting...."
        yum install httpd -y &> /dev/null
        systemctl httpd
        systmctl disable --now  firewalld
        setenforce 0
        echo "httpd is already running! "        
fi
相关推荐
小猪佩奇TONY1 小时前
Linux 内核学习(14) --- linux x86-32 虚拟地址空间
linux·学习
Lam㊣1 小时前
Centos 7 系统docker:更换镜像源
linux·docker·centos
FL16238631291 小时前
win11+WSL+Ubuntu-xrdp+远程桌面闪退+黑屏闪退解决
linux·运维·ubuntu
石头5302 小时前
Kubernetes监控全栈解决方案:从零搭建Prometheus+Grafana监控体系
linux
ha20428941942 小时前
Linux操作系统学习记录之---TcpSocket
linux·网络·c++·学习
AOwhisky2 小时前
Linux逻辑卷管理:从“固定隔间”到“弹性存储池”的智慧
linux·运维·服务器
C Yu小白4 小时前
Linux系统调用与文件操作详解
linux·运维·服务器
ZFB00014 小时前
【麒麟桌面系统】V10-SP1 2503 系统知识——常见用户组简介
linux·运维·kylin
EndingCoder4 小时前
类的继承和多态
linux·运维·前端·javascript·ubuntu·typescript
ZFB00015 小时前
【麒麟桌面系统】V10-SP1 2503 系统知识——添加用户
linux·运维·kylin