zoukankan      html  css  js  c++  java
  • 1 minute教会你shell

    Shell模板

    #!/bin/bash
    #######################################################
    # $Name:         shell_template.sh
    # $Version:      v1.0
    # $Function:     Introduce Function Template Script
    # $Author:       Zhurui
    # $organization: https://hacker.cnblog.com
    # $Create Date:  2016-11-1
    # $Description:  You know what i mean,hehe
    #######################################################
    # Shell Env
    SHELL_NAME="shell_template.sh"
    SHELL_DIR="/opt/shell"
    SHELL_LOG="${SHELL_DIR}/${SHELL_NAME}.log"
    LOCK_FILE="/tmp/${SHELL_NAME}.lock"
    #Write Log 
    shell_log(){
        LOG_INFO=$1
        echo "$(date "+%Y-%m-%d") $(date "+%H-%M-%S") : ${SHELL_NAME} : ${LOG_INFO}" >> ${SHELL_LOG}
    }
    # Shell Usage
    shell_usage(){
        echo $"Usage: $0 {backup}"
    }
    shell_lock(){
        touch ${LOCK_FILE}
    }
    shell_unlock(){
        rm -f ${LOCK_FILE}
    }
    # Backup MySQL All Database with mysqldump or innobackupex
    funcname(){
        if [ -f "$LOCK_FILE" ];then
            shell_log "${SHELL_NAME} is running"
            echo "${SHELL_NAME}" is running && exit
        fi
        shell_log "mysql backup start"
        shell_lock
        sleep 10
        shell_log "mysql backup stop"
        shell_unlock
    }
    # Main Function
    main(){
        case $1 in
            backup)
                funcname
                ;;
            *)
                shell_usage;
        esac
    }
    #Exec
    main $1
  • 相关阅读:
    【git】之常用命令
    VueJs
    如何做技术选型
    用户登录验证注意事项
    npm xss
    express-session
    ejs、jade和dust
    XMLHttpRequest.responseType
    JS对象字面量
    安装Angulr CLI
  • 原文地址:https://www.cnblogs.com/hackerer/p/6293421.html
Copyright © 2011-2022 走看看