zoukankan      html  css  js  c++  java
  • linux

    1. 不存在就创建文件夹
    if [ ! -d "ekhip/" ];then
        mkdir /opt/ekhip
    else
        echo "/opt/ekhip exists"
    fi
    
    2. 看在文件中是否有某个字符串
    grep "esbBnormal" esbBresult.txt
                    if [ $? -eq 0 ] ; 
                        then
                            ##esb2 成功
                            sleep 3s
                            ##nginx normal reload
                            ssh root@192.168.18.143 /bin/bash /opt/nginxnormal.sh
                    fi
    
    
    3. 远程连接获取返回值直接追加到文件中
    ssh root@$ip "cmd" >> ./log
    
    4. 变量赋值对于echo的好像没有用?
    result=`ssh x@B ~/command.sh`
    
    5. 是否可以在远程ssh命令中使用变量?
    http://cn.voidcc.com/question/p-pfaixobb-qy.html
    
    6. 远程拷贝 远程连接
    scp -r $PATH_EKHIP/esb root@192.168.18.144:/opt
    
    7. 在过程中遇到远程启动restart.sh 无效 然后加了source /etc/profile 就好了
    https://www.cnblogs.com/yjmyzz/p/ssh-remote-execute-shell.html
    
    
    8. 配置免密传输
    ssh-keygen -t rsa
    cd ~/.ssh
    cp -rf id_rsa.pub authorized_keys
    ##将秘钥文件拷贝到esb1
    scp -r ~/.ssh/ root@192.168.18.143:/root/
    
    9. 获取时间差
           start=`date +%s -d "$(date "+%Y-%m-%d %H:%M:%S")"`
    end=`date +%s -d "$(date "+%Y-%m-%d %H:%M:%S")"`
    diff=$(($end-$start))
    
    10. 判断是否有info文件
                a="/opt/$(getEhkippath)/$1/log/ekhip_info.`date '+%Y-%m-%d'`.0.log"
                if [ -f $a ];then
                    size=`ls -lrt $a | cut -d " " -f 5`
                    if [ $size -gt 0 ];then 
                        grep "Started MyApplication" /opt/$(getEhkippath)/$1/log/ekhip_info.`date '+%Y-%m-%d'`.0.log
                        if [ $? -eq 0 ];then
                            res=0
                            info="`date '+%T'` ## $1模块启动完毕"
                            break
                        fi
                    fi
                fi
    
    11. while循环
       while [ $diff -le $timelimit ] ##小于等于
             do
                 ...
         done

    越努力越幸运~ 加油ヾ(◍°∇°◍)ノ゙
  • 相关阅读:
    Spring的IOC容器学习笔记
    全球疫情可视化展示
    GitHub-暂存区与版本回退
    GitHub-创建仓库与本地同步
    Shell脚本常用模板
    Shell按行读取文件的3种方法
    shell脚本:通过域名获取证书的过期时间
    如何禁止chrome浏览器http自动转成https 【转】
    kafka_2.11-2.0.0_常用操作
    kafka_2.11-2.0.0_安装部署
  • 原文地址:https://www.cnblogs.com/utomboy/p/12784413.html
Copyright © 2011-2022 走看看