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. 汇编 LEA 指令

    知识点:  LEA指令  &与LEA  OD里修改汇编代码 一.LEA指令格式 有效地址传送指令 LEA 格式: LEA 操作数A, 操作数B 功能: 将操作数B的有效地址传送到指定的的 ...

  2. mfc CImageList和CListCtrl

    知识点: CImageList类的运用 CListCtrl添加图标 一.CImageList CImageList*SetImageList(CImageList*pImageList,int nIm ...

  3. java maven项目迁移时缺失jar包 或者 maven jar包缺失时的解决方案

    这样弄完,jar包就都下载好了,就不缺失了. 从GitHub上checkout一个项目下来,导入idea后发现加载依赖奇慢无比,所以临时把网络调成FQ的代理,结果会发现idea会停止之前的下载,那怎么 ...

  4. effective c++ 笔记 (1-3)

    // //  effective c++.cpp //  笔记 // //  Created by fam on 15/3/23. // // //-------------------------- ...

  5. swift学习:第一个swift ui程序

    最近swift有点火,赶紧跟上学习.于是,个人第一个swift程序诞生了... 新建项目

  6. Css_*^$

    #search_condition [class*=search_submit] 表示class name里面的值包含search_submit $("#search_condition [ ...

  7. git 跟踪提交记录

    一.克隆git仓库 git clone ssh://hwl@xxx/home/data/repositories/git.git 二.申明使用人信息,以便跟踪提交记录 $ git config --g ...

  8. allegro 封装 (引脚编号修改)

    1. 打开dra文件在find里面 off all  然后只点击text 2.点击需要更改的焊盘 3.菜单栏edit - text 4.弹出窗口修改即可

  9. SqlHelper DBHelper

    根据自己项目的开发需要,整理了一个SqlHelper类 相比较网上通用的SqlHelper类方法主要有一下几点的不同: 1.因为要操作多个数据库,所以数据库连接字符串没有写死到方法里,作为参数提供出来 ...

  10. 2-Thirteenth Scrum Meeting-10151213

    任务安排 成员 今日完成 明日任务 闫昊 获取视频播放进度  用本地数据库记录课程结构和学习进度 唐彬  阅读IOS代码+阅读上届网络核心代码  请假(编译……) 史烨轩 下载service开发    ...