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
相关推荐
不昀5 小时前
网口Link Up后仍然掉线,怎样区分物理链路和数据通路问题?
linux·以太网
Lhan.zzZ5 小时前
Qt WebEngineView 在 Linux 上无法加载网页:从“看不见 HTML“到“禁用沙箱“
linux·c++·qt
Fcy6486 小时前
Linux下 多路转接select详解
linux·select·多路转接
无足鸟ICT7 小时前
【RHCA+】RPM包命名规则
linux·运维·服务器
Zucker n8 小时前
一款适合研究生科研工作安排的日历
linux·数据库·python
爱吃香菜的初学者8 小时前
十六.Linux——多线程(2)
linux·运维·开发语言
‎ദ്ദിᵔ.˛.ᵔ₎9 小时前
Linux:对有关 SIGCHLD 的深层理解
linux·运维·服务器
aichitang202410 小时前
QCU 2.0.0:补齐 Windows、Linux 与 GNOME Wayland
linux·运维·windows·ai·agent·ai编程
Lv_沐曦10 小时前
Linux 上的Web文件管理器-filebrowser
linux·运维·服务器