一、监控脚本system.sh,存在异常时邮件告警
1、配置邮件服务 [[email protected] /]#yum -y install mailx
2、进入配置文件 [[email protected] /]# cat /etc/mail.rc
3、修改配置文件(在最后添加)在邮箱中开启pop3服务收到授权码
4、编辑shell文件 [[email protected] opt]# vi system.sh
5、给予操作的权限[[email protected] opt]# chmod a+x system.sh
6、执行该脚本文件[[email protected] opt]# ./system.sh
7、收到邮件
二、设置定时任务
1、进入编辑[[email protected] /]# crontab -e
2、编辑
三、服务HTTPD的启动脚本
#!/bin/bash
read -p “请输入需要的服务名称(dhcpd/vsftp/httpd/dns):” fw
read -p “请输入需要的操作(restart/stop/start):” cz
systemctl status dhcpd |grep “dead” |awk ‘{print $3}’
sys=echo $?
if [ $sys -eq 0 ];thensystemctl $cz $fw
echo “fw服务已开启!”
fi