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
相关推荐
orion579 小时前
Missing Semester Class1:course overview and introduction of shell
linux
用户1204872216115 小时前
Linux驱动编译与加载
linux·嵌入式
用户8055336980321 小时前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户8055336980321 小时前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
七歌杜金房1 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia2 天前
linux curl命令详解_curl详解
linux
扛枪的书生3 天前
Linux 网络管理器用法速查
linux
顺风尿一寸3 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
XIAOHEZIcode3 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫3 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux