随笔分类 - shell脚本
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}'|

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

Python----路由器远程控制
摘要:
paramiko 是用 python 语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接 一、路由器基本连接 # -*- coding:utf-8 -*- import paramiko clent = paramiko.SSHClient() # 允许连接不在know

Linux中xargs命令的使用
摘要:
xargs程序允许你从标准输入生成和执行命令,它通常通过管道与其他命令结合使用。 使用xargs,您可以提供标准输入作为命令行实用程序(例如mkdir和rm)的参数。 在本教程中,介绍使用xargs命令的基本知识。 如何使用Linux xargs命令 xargs从标准输入读取参数,用空格或换行符分隔

MHA部署实现高可用(1)
摘要:
环境准备: 三台 CentOS 7 机器 可联网 永久修改机器名称,断开三台机器xshell重连实现名称的修改 hostnamectl set-hostname c731hostnamectl set-hostname c732hostnamectl set-hostname c733 c731 1

supervisor管理单机多实例Tomcat
摘要:
操作目的:用supervisor工具管理tomcat服务 配置环境,安装服务,以及多实例 脚本编辑: 1 #!/bin/bash 2 systemctl stop firewalld 3 setenforce 0 4 echo " 安装更新 " 5 yum -y install epel-relea

shell中的通配符(grep、cut、sort等)
摘要:
一、grep工具 grep是行过滤工具;用于根据关键字进行过滤 语法: grep [ 选项 ] ‘关键字’ 文件名 1、颜色显示: --color=auto grep --color=auto 'root' passwd alias grep='grep --color=auto' 全局修改,将输入

Linux定时任务crontab命令
摘要:
linux 系统则是由 cron (crond) 这个系统服务来控制的。Linux 系统上面原本就有非常多的计划性工作,因此这个系统服务是默认启动的。另外, 由于用户自己也可以设置计划任务,所以,Linux 系统也提供了使用者控制计划任务的命令 :crontab 命令。 crond 是linux下用

脚本概述
摘要:
1.shell概念 Shell是一个用C语言编写的程序,他是用户使用linux的桥梁。shell及时一种命令语言,也是一种程序设计语言 2.shell脚本结构 shell脚本(shell script),是一种为shell编写的脚本程序。 1.开头:#!/bin/sh或#!/bin/bash 符号#

shell一键部署nginx+tomcat
摘要:
1.首先拉取环境 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

企业日常巡检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

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 ];

shell配置mysql主从
摘要:
Environment:CentOS7两台主机 一台做主机,一台做备份机 注意: 首先第一步关闭两台机器的防火墙 主机shell操作: 1 #!/bin/bash 2 slave_user='zjt' 3 slave_passwd='123' 4 slave_ipaddr='192.168.189.

shell脚本sed awk
摘要:
1 删除第一行 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'

shell脚本简单例子
摘要:
eg: Expect: 1.用环境变量RANDOM随机生成一个100以内的随机数 2.read读取当前输入 3.当前输入对比随机生成的数 4.当两个数相等时跳出苏循环,并计数(比较n次结果才相等) 1 #!/bin/bash 2 i=0 3 num=$(expr $RANDOM % 100) 4 e

基本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 ];
