当前位置: 首页 > news >正文

ce第六次作业

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

[root@Server ~]# yum install -y mailx
[root@Server ~]# yum -y install bind-utils
[root@Server ~]# vim /etc/mail.rc
set from=15339232034@163.com
set smtp=smtps://smtp.163.com:465
set smtp-auth-user=15339232034@163.com
set smtp-auth-password=PVw7kZuYqpjYij3E
set smtp-auth-login[root@Server ~]# vim remaining_disks.sh
#/bin/bash
remaining_disks=$(df -h | grep "\/$" | cut -d" " -f4 | cut -d"G" -f1)
msg="当前磁盘空间小于20g,请及时处理"
if [ ${remaining_disks} -lt 20 ]
thenecho $msg | mail -s "内存报警" 15339232034@163.com
fi[root@Server ~]# crontab -l
0 0 * * * /usr/bin/sh /root/remaining_disks.sh


​ 2、判断web服务是否运行(1、查看进程的方式判断该程序是否运行,2、通过查看端口的方式判断该程序是否运行),如果没有运行,则启动该服务并配置防火墙规则。

[root@Server ~]# vim nginx_process.sh
#/bin/bash
pro=$(netstat -lntup |grep -w 80 |wc -l)
if [ $pro -gt 0 ]
thenecho "the nginx services is running"
elseecho "the nginx services is not running"systemctl start nginxsystemctl start firewalldfirewall-cmd --permanent --zone=public --add-port=80/tcp &>/dev/nullfirewall-cmd --permanent --zone=public --add-service=http &> /dev/nullfirewall-cmd --reload &>/dev/nullecho "nginx is already running"
fi[root@Server ~]# vim nginx_process2.sh 
#!/bin/bash
pro=$(netstat -lntup | grep -w 80 | wc -l)
if [ $pro -gt 0 ]
thenecho "nginx is running"
elseecho"nginx is not running"systemctl start nginxsystemctl start firewalldfirewall-cmd --permanent --zone=public --add-service=http &>/dev/nullfirewall-cmd --permanent --zone=public --add-port=80/tcp &>/dev/null
fi[root@Server ~]# systemctl stop nginx

http://www.lryc.cn/news/509273.html

相关文章:

  • 为何页面搜索应避免左模糊和全模糊查询???
  • AI可信论坛亮点:合合信息分享视觉内容安全技术前沿
  • 在 Mac M2 上安装 PyTorch 并启用 MPS 加速的详细教程与性能对比
  • 生成式人工智能在生产型企业中的应用
  • Linux逻辑卷管理
  • 机器人加装电主轴【铣削、钻孔、打磨、去毛刺】更高效
  • opencv sdk for java中提示无stiching模块接口的问题
  • 今天最新早上好问候语精选大全,每天问候,相互牵挂,彼此祝福
  • 五种IO模型- 阻塞IO、非阻塞IO、多路复用IO、信号驱动IO以及异步IO
  • Vscode GStreamer插件开发环境配置
  • flask基础
  • Java日志框架:log4j、log4j2、logback
  • 鸿蒙-expandSafeArea使用
  • 【es6复习笔记】Spread 扩展运算符(8)
  • 第22天:信息收集-Web应用各语言框架安全组件联动系统数据特征人工分析识别项目
  • 后端-redis
  • 开发场景中Java 集合的最佳选择
  • golangci-lint安装与Goland集成
  • 金仓数据库安装-Kingbase v9-centos
  • 条款6:auto推导若非己愿,使用显式类型初始化惯用法
  • 蓝桥杯物联网开发板硬件组成
  • 视频汇聚融合云平台Liveweb一站式解决视频资源管理痛点
  • (aaai2025) FD2-Net: Frequency-Driven Feature Decomposition Network
  • 深度学习之目标检测——RCNN
  • 2014年IMO第3题
  • 国高材服务 | 高分子结晶动力学表征——高低温热台偏光显微镜
  • 跨站请求伪造之基本介绍
  • Hadoop集群(HDFS集群、YARN集群、MapReduce​计算框架)
  • 单元测试(UT,C++版)经验总结(gtest+gmock)
  • Mysql高级部分总结(二)