Shell Script Tracking

Source: Internet
Author: User

[Email protected] bin]$ sh-n restart.sh

[Email protected] bin]$

-N: Do not execute script, just check the syntax, if there is no output correctly, if there is an error, you will be prompted


[Email protected] bin]$ sh-x restart.sh

+ tomcat_home=/opt/apache-tomcat-8.0.14

+ Cd/opt/apache-tomcat-8.0.14/bin

+ + Ps-ef

+ + grep-v grep

+ + Wc-l

+ + grep/opt/apache-tomcat-8.0.14

+ Declare-i Count=1

+ ' [' 1-eq 0 '] '

+ echo ' shutdown ... '

Shutdown ...

+./shutdown.sh

Using catalina_base:/opt/apache-tomcat-8.0.14

Using Catalina_home:/opt/apache-tomcat-8.0.14

Using Catalina_tmpdir:/opt/apache-tomcat-8.0.14/temp

Using Jre_home:/usr/java/jdk1.8.0_25

Using CLASSPATH:/opt/apache-tomcat-8.0.14/bin/bootstrap.jar:/opt/apache-tomcat-8.0.14/bin/tomcat-juli.jar

+ + Ps-ef

+ + grep/opt/apache-tomcat-8.0.14

+ + grep-v grep

+ + Wc-l

+ count=1

+ ' [' 1-ne 0 '] '

+ + Ps-ef

+ + grep/opt/apache-tomcat-8.0.14

+ + grep-v grep

+ + awk ' {print $} '

+ Declare-i pid=14433

+ Kill 14433

+ Echo ' Tomcat is down '

Tomcat is down

+./startup.sh

Using catalina_base:/opt/apache-tomcat-8.0.14

Using Catalina_home:/opt/apache-tomcat-8.0.14

Using Catalina_tmpdir:/opt/apache-tomcat-8.0.14/temp

Using Jre_home:/usr/java/jdk1.8.0_25

Using CLASSPATH:/opt/apache-tomcat-8.0.14/bin/bootstrap.jar:/opt/apache-tomcat-8.0.14/bin/tomcat-juli.jar

Tomcat started.

+ Exit 0

[Email protected] bin]$

-x: Execute and Output script


[Email protected] bin]$ sh-v restart.sh

#!/bin/bash

TOMCAT_HOME=${TOMCAT_HOME:=/OPT/APACHE-TOMCAT-8.0.14}

CD $TOMCAT _home/bin

Declare-i count= ' ps-ef|grep $TOMCAT _home|grep-v "grep" |wc-l '

Ps-ef|grep $TOMCAT _home|grep-v "grep" |wc-l

If [$count-eq 0];then

echo "Tomcat is not started"

Else

echo "Shutdown ..."

./shutdown.sh

Count= ' Ps-ef|grep $TOMCAT _home|grep-v "grep" |wc-l '

If [$count-ne 0];then

Declare-i pid= ' ps-ef|grep $TOMCAT _home|grep-v "grep" |awk ' {print $} '

Kill $pid

Fi

echo "Tomcat is down"

Fi

./startup.sh

Shutdown ...

Using catalina_base:/opt/apache-tomcat-8.0.14

Using Catalina_home:/opt/apache-tomcat-8.0.14

Using Catalina_tmpdir:/opt/apache-tomcat-8.0.14/temp

Using Jre_home:/usr/java/jdk1.8.0_25

Using CLASSPATH:/opt/apache-tomcat-8.0.14/bin/bootstrap.jar:/opt/apache-tomcat-8.0.14/bin/tomcat-juli.jar

Ps-ef|grep $TOMCAT _home|grep-v "grep" |wc-l

Ps-ef|grep $TOMCAT _home|grep-v "grep" |awk ' {print $} '

Tomcat is down

Using catalina_base:/opt/apache-tomcat-8.0.14

Using Catalina_home:/opt/apache-tomcat-8.0.14

Using Catalina_tmpdir:/opt/apache-tomcat-8.0.14/temp

Using Jre_home:/usr/java/jdk1.8.0_25

Using CLASSPATH:/opt/apache-tomcat-8.0.14/bin/bootstrap.jar:/opt/apache-tomcat-8.0.14/bin/tomcat-juli.jar

Tomcat started.

Exit 0

[Email protected] bin]$

-V: Output First, then execute, the red part is the script, this is the Tomcat restart script

This article is from the "All the Way North" blog, please be sure to keep this source http://janan.blog.51cto.com/7466674/1569883

Shell Script Tracking

Related Article

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.