Java and tomcat scripts

Source: Internet
Author: User

Ava script

#! /Bin/bash
# Chkconfig: 345 99 1
# Description: java progress
# Processname: java
# Authority: amos. lu
Export PAHT = $ PATH:/bin:/usr/sbin:/sbin
Export JAVA_HOME =/usr/local/jdk1.6.0 _ 16
Export JRE_HOME =/usr/local/jdk1.6.0 _ 16
Export LOGS_USER = root
Export LOGS_HOME =/data/app/logs. playvip
Export OPT = "-jar-server-Xms512m-Xmx1024m"
Export JAVA = "/usr/local/jdk1.6.0 _ 16/bin/java"
Export NOHUP = "/usr/bin/nohup"
./Etc/init. d/functions
# [-D LOGS_HOME] | {echo "sales requires LOGS_HOME"; exit 1 ;}
JAR = 'ls $ LOGS_HOME | grep jar | grep-v grep | head-n1'
Usage (){
Echo "Usage: $0 {start | stop | restart | status }"
Exit 2
}
Function start ()
{
If ps-ef | grep "$ JAR" | grep-v grep>/dev/null
Then
[$? -Eq 0] & echo "$ JAR is already running .."
Else
$ NOHUP $ JAVA $ OPT $ LOGS_HOME/$ JAR >>$ LOGS_HOME/nohup. out 2> & 1 &
If [$? -Eq 0]
Then
Echo-e "[\ e [1; 32 m OK \ e [0 m]"
Else
Echo-e "[\ e [1; 31 m failed \ e [0 m]"
Fi
Fi
}
Function stop ()
{
If ps-ef | grep-w "$ JAR" | grep-v grep | awk '{print $2}'>/dev/null
Then
Ps auxw | grep $ JAR | grep-v grep | awk '{print $2}' | xargs kill-9 &>/dev/null
If [$? -Eq 0]
Then
Echo-e "[\ e [1; 32 m OK \ e [0 m]"
Else
Echo-e "[\ e [1; 31 m failed \ e [0 m]"
Fi
Fi
}
Function status ()
{
If ps-ef | grep-w "$ JAR" | grep-v grep>/dev/null
Then
Echo "$ JAR is aleady running .."
Else
Echo "$ JAR is not running .."
Fi
}
Case $1 in
Start)
Start
;;
Stop)
Stop
;;
Status)
Status
;;
Restart)
Stop
Start
;;
*)
Usage
;;
Esac
Exit 0

Tomcat script


#! /Bin/bash
# Chkconfig: 345 99 1
# Description: java progress
# Processname: java
# Authority: amos. lu
Export PAHT = $ PATH:/bin:/usr/sbin:/sbin
Export JAVA_HOME =/usr/local/jdk1.6.0 _ 16
Export JRE_HOME =/usr/local/jdk1.6.0 _ 16
Export LOGS_USER = root
Export LOGS_HOME =/data/app/logs. playvip
Export OPT = "-jar-server-Xms512m-Xmx1024m"
Export JAVA = "/usr/local/jdk1.6.0 _ 16/bin/java"
./Etc/init. d/functions
JAR = 'ls $ LOGS_HOME | grep jar | grep-v grep | head-n1'
Usage (){
Echo "Usage: $0 {start | stop | restart | status }"
Exit 2
}
Function start ()
{
If ps-ef | grep "$ JAR" | grep-v grep>/dev/null
Then
[$? -Eq 0] & echo "$ JAR is already running .."
Else
Su-$ TOMCAT_USER bash-c "$ CATALINA_HOME/bin/catalina. sh $1>/dev/null 2> & 1 ";
If [$? -Eq 0]
Then
Echo-e "[\ e [1; 32 m OK \ e [0 m]"
Else
Echo-e "[\ e [1; 31 m failed \ e [0 m]"
Fi
Fi
}
Function stop ()
{
If ps-ef | grep-w "$ JAR" | grep-v grep | awk '{print $2}'>/dev/null
Then
Ps auxw | grep $ JAR | grep-v grep | awk '{print $2}' | xargs kill-9 &>/dev/null
If [$? -Eq 0]
Then
Echo-e "[\ e [1; 32 m OK \ e [0 m]"
Else
Echo-e "[\ e [1; 31 m failed \ e [0 m]"
Fi
Fi
}
Function status ()
{
If ps-ef | grep-w "$ JAR" | grep-v grep>/dev/null
Then
Echo "$ JAR is aleady running .."
Else
Echo "$ JAR is not running .."
Fi
}
Case $1 in
Start)
Start
;;
Stop)
Stop
;;
Status)
Status
;;
Restart)
Stop
Start
;;
*)
Usage
;;
Esac
Exit 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.