shell编程实战21

摘要: 1. 并发备份数据库 #!/bin/bash exec &> /tmp/mysql_bak.log if ! which innobackupex &>/dev/nllthen echo "安装xtrabackup工具" rpm -ivh http://www.percona.com/downloa 阅读全文
posted @ 2019-09-23 21:30 strive_tan 阅读(183) 评论(0) 推荐(0)

shell编程实战20

摘要: 1. 部署mysql主从 #!/bin/bashmaster_ip=192.168.100.12slave_ip=192.168.100.13mysqlc="mysql -uroot -paminglinux" check_ok(){ if [ $? -ne 0 ] then echo "$1 出错 阅读全文
posted @ 2019-09-20 21:14 strive_tan 阅读(167) 评论(0) 推荐(0)

shell编程实战19

摘要: 1. 统计并发量 2. 关闭服务 3. 彻底关闭tomcat服务 #!/bin/bash dir=/usr/local/tomcat/bin/ java_pc(){ pgrep java|wc -l} cd $dir./shutdown.sh count=0 ## 连续5次killall,如果不能k 阅读全文
posted @ 2019-09-19 18:19 strive_tan 阅读(147) 评论(0) 推荐(0)

shell编程实战18

摘要: 1. 批量删除日志 2. 房贷计算器 #!/bin/bash read -p "请输入贷款总额(单位:万元):" sum_wread -p "请输入贷款年利率(如年利率为6.5%,直接输入6.5):" y_rread -p "请输入贷款年限(单位:年):" y_necho "贷款计算方式:"echo 阅读全文
posted @ 2019-09-18 22:14 strive_tan 阅读(258) 评论(0) 推荐(0)

shell编程实战17

摘要: 1. 问候用户 2. 格式化输出xml #!/bin/bash sed '/<!--.*-->/d' test.xml > test2.xml ## 注释符在一行的情况egrep -n '<!--|\-\->' test2.xml |awk -F ':' '{print $1}' > /tmp/li 阅读全文
posted @ 2019-09-17 23:42 strive_tan 阅读(181) 评论(0) 推荐(0)

shell编程实战16

摘要: 1. 监控cpu使用率 #!/bin/bash mail_user=tzr@qq.com m_mail() { log=$1 t_s=`date +%s` t_s2=`date -d "1 hours ago" +%s` if [ ! -f /tmp/$log ] then #创建$log文件 to 阅读全文
posted @ 2019-09-16 23:37 strive_tan 阅读(253) 评论(0) 推荐(0)

shell编程实战15

摘要: 1. 找两个文件的差异 2. 杀某用户的进程 3. 并发备份数据库 #!/bin/bash N=5 ## 定义并发量为5mysql="mysqldump -uaming -ppasswd mydb" $mysql -e "show tables;"|sed '1d' > /tmp/table.lis 阅读全文
posted @ 2019-09-16 23:24 strive_tan 阅读(120) 评论(0) 推荐(0)

shell编程实战14

摘要: 1. 备份etc目录 2. 给文件增加插入内容 3. 人员随机分组 #!/bin/bash f=member.txt ##人员列表,一行一个人员member_n=`wc -l $f|awk '{print $1}'`group_n=7 ##7**2,人员数开平方 ## 根据人员姓名计算该成员所在小组 阅读全文
posted @ 2019-09-16 13:52 strive_tan 阅读(219) 评论(0) 推荐(0)

shell编程实战13

摘要: 1. 检测网站是否正常 2.打包小于5KB的文件 3.监控22端口是否被封并处理 4. 分析nginx日志 5. 根据提示打印数字 #!/bin/bash read -p "please input a number" nn1=`echo $n|sed 's/[0-9]//g'`if [ -n "$ 阅读全文
posted @ 2019-09-11 22:58 strive_tan 阅读(182) 评论(0) 推荐(0)

shell编程实战12

摘要: 1. 获得网卡或ip #!/bin/bash #ip addr|grep '^[0-9]'|awk -F ':' '{print $2}' >/tmp/netcard.list#ip addr|grep -w 'inet'|awk -F '/' '{print $1}'|awk '{print $2 阅读全文
posted @ 2019-09-10 23:46 strive_tan 阅读(184) 评论(0) 推荐(0)