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
相关推荐
kTR2hD1qb44 分钟前
从 Responses API 到 Chat Completions:一个模型网关的设计复盘
linux·前端
姓刘的哦1 小时前
大模型祛魅
linux
hj2862512 小时前
linux下一步学习内容
linux·运维
xier_ran3 小时前
【infra之路】Linux基础命令与系统排查
linux·运维·服务器
zh路西法3 小时前
【Linux 串口通信】基于 C++ 多线程的同步/异步串口实现
linux·运维·c++·python
c238563 小时前
linux基础2
linux·运维·服务器
子兮曰3 小时前
WSL 配 GPU 用 Docker 的折腾指南(2026 年版)
linux·前端·后端
vortex54 小时前
Linux 默认 SUID 可执行文件详解
linux·运维
2023自学中4 小时前
Linux虚拟机 CMakeLists.txt:x86 与 ARM 双架构编译脚本
linux·c语言·c++·嵌入式
爱就是恒久忍耐5 小时前
老Ubuntu安装podman 5.x版本
linux·ubuntu·podman