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. 【Qt】QLabel实现的圆形图像

    本篇只描述圆形图像的两种实现方式,动态阴影边框如下: [Qt]QLabel之动态阴影边框 目前实现的效果如下: 左右两边实现的方式不同: 右边比较简单 min-width: 100px; max-wi ...

  2. 【2017年9月10日更新】ABP配套代码生成器(ABP Code Generator)帮助文档,实现快速开发

    ABP代码生成器介绍 ABP Code Generator 针对abp这个框架做了一个代码生成器,功能强大.分为两大功能点,一个是数据层,一个是视图层. 数据服务层:通过它,可以实现表设计.领域层初始 ...

  3. EntityFramework Core 2.x (ef core) 在迁移中自动生成数据库表和列说明

    在项目开发中有没有用过拼音首字母做列名或者接手这样的项目? 看见xmspsqb(项目审批申请表)这种表名时是否有一种无法抑制的想肛了取名的老兄的冲动? 更坑爹的是这种数据库没有文档(或者文档老旧不堪早 ...

  4. libimobiledevice --Mingw32交叉编译

    本文只描述 windows环境下的使用情况,linux平台基本雷同. 一.配置编译环境. (1)操作系统 :Windows10 (64bit). (2)类unix环境:Cygwin(64bit) 下载 ...

  5. A1006. Sign In and Sign Out(25)

    25/25,一遍过了,很开心. #include<bits/stdc++.h> using namespace std; struct record{ string id; string ...

  6. 软件项目第一次sprint评分表

  7. Android的环境搭建

    尽管以前并没有接触过软件开发.但是,现在网络资源实在是太丰富了.所以网搜了一下,认为Android的环境搭建可分为以下五个步骤来完成.第一步:安装JDK:第二步:配置Windows上JDK的变量环境: ...

  8. Java 笔记——在 IDEA 中使用 Maven 配置和使用 MyBatis

    1.前言 MyBatis 是什么? MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射. MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集. ...

  9. 对于beta发布的评论

    第一组:新蜂小组 题目:俄罗斯方块 评论:主体功能已经完成,可以流畅的进行游戏,看项目的完成度是最高的.他们不但把核心功能做出来了,界面也已基本完成. 第二组:Nice团队 题目:约跑APP(约吧) ...

  10. 用javaScript将页面滚动条到底部

    ((JavascriptExecutor) driver).executeScript("document.body.scrollTop=500000"); 通过该方法可以将有滚动 ...