- 博客(9)
- 收藏
- 关注
原创 shell-脚本(IP判断)
需求: 生成一个ip.txt文件 判断:当ip为192开头的,显示这个ip是ok的,当ip为172开头的,就调用iptables drop掉 生成IP.txt文件并键入ip vim ip.txt 写入: 192.168.1.1 192.168.1.2 172.129.1.1 172.129.1.2 shell脚本: #!/bin/bash ip=(`cat /root/ip.txt`) for i in ${ip[@]} #循环遍历变量 do if [[ $..
2020-06-26 18:30:49
1251
原创 shell-脚本_判断文件属性
运算符 作用 运算符 作用 e 如果 filename存在,则为真 d 如果 filename为目录,则为真 f 如果 filename为常规文件,则为真 L 如果 filename为符号链接,则为真 r 如果 filename可读,则为真 w 如果 filename可写,则为真 x 如果 filename可执行,则为真 ** –nt ** 如果 filename1比 filename2新,则为真 .
2020-06-22 01:47:30
1015
原创 shell-expect 模拟交互
系统环境 centos7 yum -y install expect shell脚本 #!/usr/bin/expect spawn ssh root@192.168.190.129 #执行命令 expect { "(yes/no)?"{ send "yes/r";exp_continue} #匹配关键字后执行命令 "password:"{ send "123456\r"} } expect"]#" send "if
2020-06-22 01:01:50
261
原创 shell-脚本_检测网站是否在线+邮件报警
#!/bin/bash website=( www.baidu.com www.csdn.net www.149843com ) #把要检测的域名定义为一个数组循环遍历检测 for url in ${website[@]} do code=$(curl -L -I -m 2 -o /dev/null -s -w %{http_code} $url) #检测网站域名是否在线,有的网站会有坑,返回301或302,添加-L选项,获取重定向界面 #等.
2020-06-22 00:34:19
390
原创 shell-随机数猜测
#!/bin/bash sj=$(expr $RANDOM % 100) #随机数生成 while true#死循环 do read -p "请输入一个随机数" num #键入数字 if [ $sj -eq $num ];then echo "恭喜你猜对了数字为$num" exit 0#成功猜对退出 elif [ $num -gt $sj ];then#判断键入数字是否大于随机数 echo "猜大了" else echo "猜小了" .
2020-06-22 00:11:15
405
原创 shell-企业级巡检自动化(简单)
系统版本centos7 shell代码 #!/bin/bash cpu_info(){ #cpu信息 /proc/cpuinfo里 #cpu 型号 cpu_model=$(cat /proc/cpuinfo |grep "model name"|uniq |awk -F ':' '{print $2}') echo "cpu的型号信息:${cpu_model}" #cpu的核心数 cpu_core=$..
2020-06-17 23:44:28
361
原创 shell-数据库分库分表备份+任务定时计划
环境配置: 虚拟机:centos7 yum -y install mariadb mariadb-server // 安装mysql shell脚本: #!/bin/bash date=`date +%Y-%m-%d` #时间变量 data=`mysql -e "show databases" | grep -v Database` #库变量 for i in $data do [ -d /opt/$date/$i ] || mkdir -p /opt/$date/$i..
2020-06-16 22:44:57
194
原创 mysql主从的搭建+shell实现检测并邮件报警
主从同步: https://blog.csdn.net/mrhsp/article/details/106795966 shell脚本: 环境安装 yum -y install malix //邮件报警模块 vim /etc/mail.rc //修改配置文件 #在里面最底部添加 set from= //用什么邮箱发送 set smtp=smtp.qq.com // 模块 set smtp-auth-user= // 什么邮件接收 set smtp-auth-password=bxizr...
2020-06-16 22:28:56
264
原创 MYSQL主从复制
部署环境(保证网络通畅) 系统环境:centos7 主服务器ip:192.168.190... 从服务器ip:192.168.190... 关闭防火墙: systemctl stop firewalld.service setenforce 0 安装mysql yum -y install mariadb mariadb-server 修改配置文件(主从一样id不同) vim /etc/my.cnf //在其中任意地方加入下面两行 log_bin=mys...
2020-06-16 22:16:44
162
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅