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
相关推荐
未济1 天前
linux 配置环境变量
linux
傲世仙尊1 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
_艾伦 耶格尔.1 天前
进程间通信
linux
Liuqy-051 天前
Linux IO编程——静态库、动态库
linux
彧azz1 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅1 天前
linux(8) 软硬链接
linux·运维·服务器
AIgorithmGEEK1 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid
琥珀色糖1 天前
SimlpeHttp
linux·服务器
qeen871 天前
【Linux】操作系统之进程介绍(二)
linux·笔记·学习·进程
Zenova EdgeOS1 天前
Linux ss 工业边缘网络分析实战
linux·python·边缘计算·工业网关