随笔分类 -  shell脚本

The study
摘要:Linux-批量ping 批量端口探真批量测试 ip/domain 连通性 #!/bin/bash echo Start ping for i in `/usr/bin/cat ~/agent/ping_list/domain` do code=`ping -c 4 -W 3 $i|grep loss|awk '{print $6}'| 阅读全文
posted @ 2022-01-12 14:27 Security 阅读(866) 评论(0) 推荐(0)
摘要:Nginx日志切割 定时清理先确定nginx日志路径和pid路径 日志路径在 /var/opt/nginx/log/nginx(access,error).log pid路径在 /var/opt/nginx/run/nginx/nginx.pid 创建日志切割后的存放路径 mkdir -p /var/lib/nginx/log 阅读全文
posted @ 2021-11-25 12:23 Security 阅读(771) 评论(0) 推荐(0)
摘要:Python----路由器远程控制paramiko 是用 python 语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接 一、路由器基本连接 # -*- coding:utf-8 -*- import paramiko clent = paramiko.SSHClient() # 允许连接不在know 阅读全文
posted @ 2021-03-22 15:33 Security 阅读(485) 评论(0) 推荐(0)
摘要:Linux中xargs命令的使用xargs程序允许你从标准输入生成和执行命令,它通常通过管道与其他命令结合使用。 使用xargs,您可以提供标准输入作为命令行实用程序(例如mkdir和rm)的参数。 在本教程中,介绍使用xargs命令的基本知识。 如何使用Linux xargs命令 xargs从标准输入读取参数,用空格或换行符分隔 阅读全文
posted @ 2020-11-19 13:51 Security 阅读(387) 评论(0) 推荐(1)
摘要:MHA部署实现高可用(1)环境准备: 三台 CentOS 7 机器 可联网 永久修改机器名称,断开三台机器xshell重连实现名称的修改 hostnamectl set-hostname c731hostnamectl set-hostname c732hostnamectl set-hostname c733 c731 1 阅读全文
posted @ 2020-02-13 18:27 Security 阅读(292) 评论(0) 推荐(0)
摘要:supervisor管理单机多实例Tomcat操作目的:用supervisor工具管理tomcat服务 配置环境,安装服务,以及多实例 脚本编辑: 1 #!/bin/bash 2 systemctl stop firewalld 3 setenforce 0 4 echo " 安装更新 " 5 yum -y install epel-relea 阅读全文
posted @ 2020-02-09 19:48 Security 阅读(329) 评论(0) 推荐(0)
摘要:shell中的通配符(grep、cut、sort等)一、grep工具 grep是行过滤工具;用于根据关键字进行过滤 语法: grep [ 选项 ] ‘关键字’ 文件名 1、颜色显示: --color=auto grep --color=auto 'root' passwd alias grep='grep --color=auto' 全局修改,将输入 阅读全文
posted @ 2020-02-05 18:33 Security 阅读(2182) 评论(0) 推荐(0)
摘要:Linux定时任务crontab命令linux 系统则是由 cron (crond) 这个系统服务来控制的。Linux 系统上面原本就有非常多的计划性工作,因此这个系统服务是默认启动的。另外, 由于用户自己也可以设置计划任务,所以,Linux 系统也提供了使用者控制计划任务的命令 :crontab 命令。 crond 是linux下用 阅读全文
posted @ 2019-12-18 14:27 Security 阅读(779) 评论(0) 推荐(0)
摘要:脚本概述1.shell概念 Shell是一个用C语言编写的程序,他是用户使用linux的桥梁。shell及时一种命令语言,也是一种程序设计语言 2.shell脚本结构 shell脚本(shell script),是一种为shell编写的脚本程序。 1.开头:#!/bin/sh或#!/bin/bash 符号# 阅读全文
posted @ 2019-12-08 20:06 Security 阅读(552) 评论(0) 推荐(0)
摘要:shell一键部署nginx+tomcat1.首先拉取环境 tomcat需要用到jdk环境 提前准备好nginx源码包,放于指定目录下 vim test.sh #!/bin/bash yum -y install gcc gcc-c++ zlib-devel pcre-devel tar zxf nginx-1.16.1.tar.gz cd 阅读全文
posted @ 2019-12-07 11:22 Security 阅读(332) 评论(0) 推荐(0)
摘要:企业日常巡检shell脚本Linux内部查看系统信息 $INTERNET192忽略 1 [root@ mysql-master ~]# ip a|grep eth0|grep inet|cut -d' ' -f6|cut -d'/' -f1 2 10.0.0.21 3 4 [root@ mysql-master ~]# if 阅读全文
posted @ 2019-12-05 17:01 Security 阅读(637) 评论(0) 推荐(0)
摘要:shell脚本通过文件里面的网址,判断是否访问成功网址 1 #!/bin/bash 2 check(){ 3 code=`curl -I -m 10 -o /dev/null -s -w %{http_code} http://$url` 4 echo $code 5 if [ $code -eq 200 ]; 阅读全文
posted @ 2019-12-02 21:00 Security 阅读(186) 评论(0) 推荐(0)
摘要:shell配置mysql主从Environment:CentOS7两台主机 一台做主机,一台做备份机 注意: 首先第一步关闭两台机器的防火墙 主机shell操作: 1 #!/bin/bash 2 slave_user='zjt' 3 slave_passwd='123' 4 slave_ipaddr='192.168.189. 阅读全文
posted @ 2019-12-02 20:25 Security 阅读(432) 评论(0) 推荐(0)
摘要:shell脚本sed    awk1 删除第一行 2 3 sed '1d' test.txt 假装执行 4 5 sed -i '1d' test.txt 执行 6 7 从第二行删除到行尾 8 9 sed '2,$d' test.txt 10 11 sed -i '2,$d' test.txt 12 13 sed -i '2,4d' 阅读全文
posted @ 2019-12-02 16:04 Security 阅读(837) 评论(0) 推荐(0)
摘要:shell脚本简单例子eg: Expect: 1.用环境变量RANDOM随机生成一个100以内的随机数 2.read读取当前输入 3.当前输入对比随机生成的数 4.当两个数相等时跳出苏循环,并计数(比较n次结果才相等) 1 #!/bin/bash 2 i=0 3 num=$(expr $RANDOM % 100) 4 e 阅读全文
posted @ 2019-11-30 10:41 Security 阅读(229) 评论(0) 推荐(0)
摘要:基本shell脚本1 #!/bin/bash 2 attr=() 3 num=0 4 while true 5 do 6 read -p ">>input:" name 7 attr[$num]=$name 8 echo ${attr[$num]} 9 let num++ 10 if [ $num -eq 3 ]; 阅读全文
posted @ 2019-11-29 15:22 Security 阅读(521) 评论(0) 推荐(1)