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

    越努力越幸运~ 加油ヾ(◍°∇°◍)ノ゙
  • 相关阅读:
    【节流】在vue的搜寻功能中使用节流
    【本地存储】将数据存储到本地 (sessionStorage、vuex)
    【react】 react---项目的-----------简单路由配置
    观察者模式
    vue-awesome-swiper 的安装和使用
    BetterScroll、移动端、滚动事件,如何使用
    永乐接口
    Linux命令
    对称加密和非对称加密
    小程序
  • 原文地址:https://www.cnblogs.com/utomboy/p/12784413.html
Copyright © 2011-2022 走看看