
shell
常用shell脚本
一默1991
The master has failed more times than the beginners have even tried.
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
扫描文件版本
#! /bin/bash function judge() { K8sCluster=$1 #Dir=webapps/ROOT/WEB-INF/lib/ Dir=$2 FileName=$3 FileFullName=$4 rm -f /tmp/detail.list rm -f /tmp/app.list for pod in $(kubectl get pod | grep dmo | awk '{print $1}') do.原创 2021-08-09 17:15:47 · 143 阅读 · 0 评论 -
k8s replicaset数量扫描
#!/bin/bash CURRENT_PATH=$(cd "$(dirname "$0")"; pwd) rm -f /tmp/replicaset rm -f /tmp/replicaset.json cp $CURRENT_PATH/list.json /tmp/replicaset.json ansible -u ec2-user --key-file /home/ec2-user/.ssh/nx2.pem -i /etc/ansible/hosts 172.37.100.71 -m copy.原创 2021-06-03 09:59:21 · 559 阅读 · 0 评论 -
查照待升级镜像
rm -f /tmp/{1,2,3,4} kubectl get deployment -owide | grep dmo | awk '{print $1}' | sort | uniq > /tmp/1 for i in $(cat /tmp/1) do isBeta=$(kubectl get deployment $i -o yaml | grep APPLICATION_TAG -A 1 | grep beta | wc -l) if [ 0 -eq $isBeta ]; the.原创 2021-05-21 17:17:35 · 147 阅读 · 0 评论 -
mongodb数据备份
/home/ec2-user/mongodump -h 172.35.88.77 -u*** -p*** --port 27017 --authenticationDatabase *** -o /home/***/backup/`date "+%F-%H-%M"` --gzip &> /home/***/backup/mongodump.log cd /home/ec2-user/backup/ ; find ./ -maxdepth 1 -type d -ctime +15 -exe.原创 2021-03-27 20:18:05 · 139 阅读 · 0 评论 -
编造测试数据
#! /bin/bash ran_total(){ x=`echo {2..6}` array=($x) num=$(($RANDOM%5)) total=`echo ${array[${num}]}` echo ${total} } ran_order(){ x=`echo {$1..$2}` array=($x) range=$2-$1 num=$(($RANDOM%$range)) order=`echo ${array[${num}]}` echo ${orde.原创 2021-03-24 15:31:04 · 313 阅读 · 1 评论 -
批量从images中获取app+config
#!/bin/bash #在K8s-master节点 172.37.101.71 执行,获取镜像列表/tmp/image #Step1: # kubectl get pod | grep "dmo" | grep Running | awk '{print $1}' > /tmp/pods #Step2: # for i in $(cat /tmp/pods);do j=$(kubectl describe pod $i | grep Image: | awk '{print $2}'); r=$(.原创 2021-02-24 13:59:30 · 191 阅读 · 0 评论 -
docker image —— x86 转 arm64
#!/bin/bash set -e DIR_PATH=$(cd "$(dirname "$0")"; pwd) cat $DIR_PATH/images | grep "set -e ; bin/catalina.sh run" > $DIR_PATH/images_update #cat $DIR_PATH/images.org > $DIR_PATH/images_update # Linux sed -i 's#registry.bizsaas.net#registry.bi...原创 2020-12-26 16:48:48 · 5437 阅读 · 0 评论 -
多环境请求测试版
#!/bin/bash URL_DEV3_export_to_file="http://localhost:7080/export/toJson?path=" URL_DEV3_import_from_file="http://localhost:7080/import/fromJson?path=" URL_POC_export_to_file="http://localhost:8080/export/toJson?path=" URL_POC_import_from_file="http://loc.原创 2020-12-01 19:46:18 · 126 阅读 · 0 评论 -
shell_笔记
$0 这个程式的执行名字 $n 这个程式的第n个参数值,n=1..9 $* 这个程式的所有参数,此选项参数可超过9个。 $# 这个程式的参数个数 $$ 这个程式的PID(脚本运行的当前进程ID号) $! 执行上一个背景指令的PID(后台运行的最后一个进程的进程ID号) $? 执行上一个指令的返回值 (显示最后命令的退出状态。0表示没有错误,其他任何值表明有错误) $- 显示shell使用的当前选项,与set命令功能相同 $@ 跟$*类似,但是可以当作数组用 ...原创 2020-11-11 16:51:22 · 92 阅读 · 0 评论 -
shell_005_start_stop_jar
#! /bin/bash #script to start jar in background. #Author: wuyue1991 export LANG="en_US.UTF-8" export LC_ALL="en_US.UTF-8" export PATH=$JAVA_HOME/bin:$PATH CURRENT_PATH=$(cd "$(dirname "$0")"; pwd) JAR=$(find $CURRENT_PATH -maxdepth 1 -name "*.jar") PID=.原创 2020-12-01 11:08:39 · 152 阅读 · 0 评论 -
shell_004_eval+awk_docker镜像导出备份
1.考虑到国内网络pull部分镜像速度很慢,每次升级k8s集群后,对控制节点和工作节点各进行一次镜像备份,便于快速恢复 2.可以定期对工作节点镜像进行一次全备份 ...原创 2020-03-23 12:14:56 · 242 阅读 · 0 评论 -
shell_003_sed_记一次应用数据库密码修改
如果是在root用户下操作,要切换执行脚本的用户 # su - username-s /bin/bash changepwd.sh原创 2020-03-22 16:58:42 · 186 阅读 · 0 评论 -
shell_002_for循环_批量导入docker镜像
#!/bin/bash cd /root/k8s-install/kubeadm-basic.images/ ls /root/k8s-install/kubeadm-basic.images/ | grep -v load-images.sh > /tmp/k8s-images.txt for i in $( cat /tmp/k8s-images.txt ) do do...原创 2020-03-22 16:45:26 · 910 阅读 · 0 评论 -
shell_001_循环嵌套_到底有没有作弊,你说呢
后台运行: # nohup sh forget2.sh > /dev/null &原创 2020-03-22 16:05:18 · 217 阅读 · 0 评论