WORKSPACE=$(cd $(dirname $0)/; pwd)
cd $WORKSPACE
 
mkdir -p var
 
module=jmxmon
version=0.0.2
app="$module-$version-jar-with-dependencies.jar"
conf=conf.properties
sampleconf=conf.example.properties
pidfile=var/app.pid
logfile=var/app.log
 
function check_pid() {
    if [ -f $pidfile ];then
        pid=`cat $pidfile`
        if [ -n $pid ]; then
            running=`ps -p $pid|grep -v "PID TTY" |wc -l`
            return $running
        fi
    fi
    return 0
}
 
function start() {
    check_pid
    running=$?
    if [ $running -gt 0 ];then
        echo -n "$app now is running already, pid="
        cat $pidfile
        return 1
    fi
 
    if ! [ -f $conf ];then
        echo "Config file $conf doesn't exist, creating one."
        cp $sampleconf $conf
    fi
    nohup java -cp ./$app com.stephan.tof.jmxmon.JMXMonitor $conf &> $logfile &
    sleep 1
    running=`ps -p $! | grep -v "PID TTY" | wc -l`
    if [ $running -gt 0 ];then
        echo $! > $pidfile
        echo "$app started..., pid=$!"
    else
        echo "$app failed to start."
        return 1
    fi
}
 
function stop() {
    pid=`cat $pidfile`
    kill $pid
    rm -f $pidfile
    echo "$app stoped..."
}
 
function restart() {
    stop
    sleep 1
    start
}
 
function status() {
    check_pid
    running=$?
    if [ $running -gt 0 ];then
        echo started
    else
        echo stoped
    fi
}
 
function tailf() {
    tail -f $logfile
}
 
 
function help() {
    echo "$0 start|stop|restart|status|tail"
}
 
if [ "$1" == "" ]; then
    help
elif [ "$1" == "stop" ];then
    stop
elif [ "$1" == "start" ];then
    start
elif [ "$1" == "restart" ];then
    restart
elif [ "$1" == "status" ];then
    status
elif [ "$1" == "tail" ];then
    tailf
else
    help
fi
 
 
 

#!/bin/sh
function install_php {
yum install vim -y
echo -e "---------------------------------------------------"
}

function install_nginx {
yum install gc -y
echo -e "---------------------------------------------------"
}
hile true
do
read -p 'plase input:' num
if [ "$num" == "1" ];then
install_php
elif [ "$num" == "2" ];then
install_nginx
else
echo '输入错误'
fi
done
exit 1

shell常用编程格式的更多相关文章

  1. SHELL脚本编程的常识和VI常用技巧

    来源:http://mprc.pku.edu.cn/mentors/training/TrainingCourses/material/ShellProgramming.HTM#_Toc3751808 ...

  2. Linux shell脚本编程(一)

    Linux shell脚本编程: 守护进程,服务进程:启动?开机时自动启动: 交互式进程:shell应用程序 广义:GUI,CLI GUI: CLI: 词法分析:命令,选项,参数 内建命令: 外部命令 ...

  3. 【Linux】Shell脚本编程(一)

    Linux shell脚本编程: 守护进程,服务进程:启动?开机时自动启动: 交互式进程:shell应用程序 广义:GUI,CLI GUI: CLI: 词法分析:命令,选项,参数 内建命令: 外部命令 ...

  4. linux shell 常用基本语法

    转自网络,真正来源不详.... 一. Linux基本命令 1.1.  cp命令 该命令的功能是将给出的文件或目录拷贝到另一文件或目录中,功能十分强大. 语法: cp [选项] 源文件或目录 目标文件或 ...

  5. Shell脚本编程的常识

    (这些往往是经常用到,但是各种网络上的材料都语焉不详的东西,个人认为比较有用) 七种文件类型 d            目录                                       ...

  6. shell脚本编程常识

    (这些往往是经常用到,但是各种网络上的材料都语焉不详的东西,个人认为比较有用) 七种文件类型 d            目录                                       ...

  7. Linux Shell脚本编程

    ⒈为什么要学习Shell编程 1)Linux运维工程师在进行服务器集群管理时,需要编写Shell程序来进行服务器管理 2)对于JavaEE和Python程序员来说,有些工作需要编写一些Shell脚本进 ...

  8. 08 bash特性--shell脚本编程入门

    shell脚本编程入门 编程语言介绍 编程语言分为:机械语言.汇编语言和高级语言: 计算机能识别的语言为机械语言,而人类能学习的并且能够方便掌握的为高级语言,所以,我们所编写的程序就要通过编译来转换成 ...

  9. 【Shell脚本编程系列】Shell脚本开发的习惯和规范

    1.开头指定脚本解释器 #!/bin/sh或#!/bin/bash 2.开头加版本版权信息 #Date #Author #Mail #Function #Version 提示:可配置vim编辑文件时自 ...

随机推荐

  1. python sorted三个例子

    # 例1. 按照元素出现的次数来排序 seq = [2,4,3,1,2,2,3] # 按次数排序 seq2 = sorted(seq, key=lambda x:seq.count(x)) print ...

  2. Ubuntu+Qt+OpenCV+FFMPEG环境搭建

    基于ubuntu16.04下opencv3.2安装配置 Ubuntu16.04下安装FFmpeg(超简单版) Qt编译后提示: /usr/bin/ld: 找不到 -lGL 安装libGL: sudo ...

  3. 生成本地测试用https证书,支持通配符和多域名,初学OpenSSL

    18-01-26在v2ex上看到一妹纸发的<身为一个 21 岁的年轻程序员,我已经腰突了(躺>,哈哈,感同身受,想到这几天我左腿麻木持续了好几天,前几天屁股疼的只要坐下就站不起来,不过站着 ...

  4. 设计模式 笔记 装饰模式 Decorator

    //---------------------------15/04/17---------------------------- //Decorator 装饰模式----对象结构型模式 /* 1:意 ...

  5. WPF DataGrid列设置为TextBox控件的相关绑定

    在wpf的DataGrid控件中,某一列的数据模板为TextBox控件的话,绑定Text="{Binding TxtSn, UpdateSourceTrigger=PropertyChang ...

  6. EVA索赔系统JAVA拦截例外站点

    控制面板->JAVA->JAVA控制面板->安全->添加以下例外站点: https://aftersales.i.daimler.com https://swdist.afte ...

  7. CEPH FILESYSTEM

    参考文档: CEPH FILESYSTEM:http://docs.ceph.com/docs/master/cephfs/ CephFS best practices:http://docs.cep ...

  8. [T-ARA][결혼 하지마][不要结婚]

    歌词来源:http://music.163.com/#/song?id=27808773 作曲 : 二段横踢 [作曲 : 二段横踢] 作词 : 二段横踢 [作词 : 二段横踢] Hey anybody ...

  9. PAT甲题题解-1062. Talent and Virtue (25)-排序水题

    水题,分组排序即可. #include <iostream> #include <cstdio> #include <algorithm> #include < ...

  10. 基于Activiti工作流引擎实现的请假审核流程

    概要 本文档介绍的是某商用中集成的Activiti工作流的部署及使用,该框架用的Activiti版本为5.19.0.本文档中主要以一个请假流程为例子进行说明,该例子的流程图如下: 这是一个可以正常运作 ...