> 文章列表 > SHELL环境变量和引用

SHELL环境变量和引用

SHELL环境变量和引用

目录

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

a.安装邮件服务

b.创建脚本对要求进行设计

c.编辑配置文件

​编辑d.做计划任务

​编辑

e.进行测试

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

a.安装httpd服务

b.创建脚本

c.进行测试

d.通过查看端口的方式判断该程序是否运行

- 3、使用curl命令访问第二题的web服务,看能否正常访问,如果能正常访问,则返回web server is running;如果不能正常访问,返回12状态码。

 a.创建脚本

 b.进行测试


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

a.安装邮件服务

[root@srever ~]# yum install s-nail -y

b.创建脚本对要求进行设计

[root@srever ~]# vim choice1.sh

c.编辑配置文件

[root@srever ~]# vim /etc/s-nail.rc


d.做计划任务

[root@server ~]# vim /etc/crontab 

e.进行测试

[root@srever ~]# bash choice1.sh 
s-nail: Warning: variable superseded or obsoleted: smtp
s-nail: Warning: variable superseded or obsoleted: smtp-auth-user
s-nail: Warning: variable superseded or obsoleted: smtp-auth-password
s-nail: Obsoletion warning: please do not use *smtp*, instead assign a smtp:// URL to *mta*!
s-nail: Obsoletion warning: Use of old-style credentials, which will vanish in v15!
s-nail:   Please read the manual section "On URL syntax and credential lookup"
s-nail: SMTP server: 535 Login Fail. Please enter your authorization code to login. More information in http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
/root/dead.letter 10/279
s-nail: ... message not sent

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

a.安装httpd服务

[root@server ~]# yum install httpd -y

b.创建脚本

[root@srever ~]# vim choice2.sh

c.进行测试

[root@srever ~]# bash choice2.sh 
httpd not started ,waiting……
httpd is already running!

d.通过查看端口的方式判断该程序是否运行

[root@srever ~]# ss -lntup  | grep -w 80 | wc -l
1

- 3、使用curl命令访问第二题的web服务,看能否正常访问,如果能正常访问,则返回web server is running;如果不能正常访问,返回12状态码。

 a.创建脚本

[root@srever ~]# vim choice3.sh

 b.进行测试

[root@srever ~]# bash choice3.sh 
web server is running