zoukankan      html  css  js  c++  java
  • source和sh

    写了一个脚本【xxyScript.sh】,用于判断tomcat是否启动

    #!/bin/bash 
    if [ -z "$(ps -ef | grep tomcat | grep -v 'grep tomcat' | awk -F ' ' '{print $2}'| awk -F ' ' '{print $1}')" ]; then 
        {
            echo "***************************the tomcat has shutdwon , I want to startp it******************************";
            sleep 3; 
            #//home/tomcat/tomA/bin/startup.sh; 
            echo "****************************the tomcat has startp ,and you can look tomA_log for it************************************";
            sleep 3; 
            #tail -f /home/tomcat/tomA/logs/catalina.out;
        }
    fi
    if [ -n "$(ps -ef | grep tomcat | grep -v 'grep tomcat' | awk -F ' ' '{print $2}'| awk -F ' ' '{print $1}')" ]; then 
        {
            echo "*************************the tomcat is startp************************************";
        }
    fi 
    然后使用命令执行:sh /home/tomcat/xxyScript.sh  ,如下图提示
    然后使用命令: source /home/tomcat/xxyScript.sh ,如下图提示,说明了脚本被正常执行了
     
    在找度娘后,看到有人解释:
    原因是source就是直接在本shell下执行,直接读取脚本中命令行并执行,而sh则是新建了一个子shell,然后运行脚本
  • 相关阅读:
    排序规则
    revert
    添加字段modify
    修改字段名change
    修改字段注释modify
    修改字段类型modify
    file类型input框赋值
    disabled
    js失去焦点触发
    别把软件开发当做养家糊口的工具...
  • 原文地址:https://www.cnblogs.com/xxyBlogs/p/5706997.html
Copyright © 2011-2022 走看看