Shell Common operations

Source: Internet
Author: User
Tags stop script

1. Read the value of the Jdbc_url parameter in the configuration file ($InputParamFile the absolute path of the destination file to be read)

Jdbc_url= ' grep ' Jdbc_url ' $InputParamFile | Awk-f ' = ' {print $} '

2. Modify the value of the configuration file Jdbc_url parameter (${jdbcconfigfilepath} is the absolute path of the destination file to be modified)

Sed-i "s#\${jdbc_url}#${jdbc_url}#" ${jdbcconfigfilepath}

3. Start the jetty script

jetty_port=1$1App_home=' pwd ' App_status () {Port= ' Ps-aef | grep STOP. port=19393| Sed-n'1p'| Awk'{if ($8~/java/) print $9}'| awk-f='{print $}'`             if[ -Z $port]; Thenreturn 1fiif["$port"=="$JETTY _port" ] ; Thenreturn 0        Else                return 1fi}ifapp_status; then echo"app is running now ....."ElseJava-dstop. port= $JETTY _port-djava.net.preferipv4stack=true-server-xms1g-xmx1g-xmn256m-xx:permsize=256m-xx:maxpermsize=256m-xx:survivorratio= +-xx:maxtenuringthreshold=3-xx:+useparnewgc-xx:+useconcmarksweepgc-xx:+usecmscompactatfullcollection-xx:cmsfullgcsbeforecompaction=0-xx:+cmsclassunloadingenabled-xx:-cmsparallelremarkenabled-xx:cmsinitiatingoccupancyfraction= --xx:softreflrupolicymspermb=0-djava.util.logging.config.file="$YACS _home/yacs/conf/log4j.xml"-jar Start.jar &fi

4. Stop Jetty Script

 # $JAVA _run $JETTY _opts-jar start.jar--stop# del by xxx endjsdir  = ' pwd ' PS -ef|grep 19393  |grep-v  " grep   " |awk "  { Print $ {}   " |xargs kill-9  downtime  = ' date +%y/%m/%d '   ' %a< Span style= "color: #800000;" > " " %h:%m:%s ' echo -e  " \n\napp shutdown-time is: $DOWNTIME \ n \ nthe   >>app/log/error/app-error.log 

5. View Jetty Running Status

#!/bin/sh## All rights reserved#-------------------------------------------------------------------------------# Environment Variable Prequisites before Start/stop Script forThe Jetty server## jetty_home may point at your Jetty setup directory.## java_home must point at your Java Development Kit installation.# Required to run the"Debug"Or"Javac"argument.## Jre_home must point @ your Java development Kit installation.# Defaults to JA Va_homeifempty.## Jetty_port must point at your JETTY stop PORT when you start JETTY server.## java_opts (Opti onal) Java runtime options used when the"Start",#                   "Stop", or"Run"Command isexecuted.## jetty_run (Optional) output terminal when to start JETTY server.## jpda_opts (Optional) J Ava runtime options used when the"JPDA Start"# command isexecuted. If used, Jpda_transport, jpda_address,# and Jpda_suspend are ignored. Thus, all required jpda# options must be specified. thedefault  is:##                   -agentlib:jdwp=transport=$JPDA _transport,# Address= $JPDA _address,server=y,suspend=$JPDA _suspend## jetty_opts must point at if to start JETTY server, which can show JETTY # s Top port.#---------------------------------------------------------------------------------BINDIR= ' DirName $0`if[-N"$BINDIR" ] ; Then Jetty_home= ' CD $BINDIR >/dev/NULL 2>&1&&pwd ' Export Jetty_homefiif[-Z"$JETTY _home" ] ; Thenif[-N"$BINDIR" ] ; Then Jetty_home= ' CD $BINDIR >/dev/NULL 2>&1&&pwd ' Export jetty_home fifi#Setjava_home variable here. #JAVA_HOME=/usr/local/test/jdk1.5. 0_22if[-N"$JAVA _home"  ] ; Then Java_run= $JAVA _home/bin/Java Export Java_homeElseJava_run= ' which Java2>/dev/NULL `    if[-Z"$JAVA _run" ] ; Then Java_run=Java fifi#SetJetty Start Optionsjetty_port=19393jetty_opts="-dstop. port= $JETTY _port-dstop. Key=secret"Jetty_run="tail-f nohup.out"#SetProduct Name forAppproduct_name=appexport java_runexport PATH="$JETTY _home/bin: $PATH"#decide Yacs status#return 0Represent Yacs isrunning#return 1Represent Yacs isNot Runningyacs_status () {Port= ' Ps-aef | grep STOP. port= $JETTY _port | Sed-n'1p'| Awk'{if ($8~/java/) print $9}'| awk-f='{print $}'' echo $portif[ -Z $port]; Thenreturn 1fiif["$port"=="$JETTY _port" ] ; Thenreturn 0     Else         return 1fi}

6. Restart Jetty

./ten. /startiuc.sh

7. Import MySQL Data

 installorupdatemysql () { if  [$ REBUILDDDB = =  n   " ];then  return    "  start create MySQL userdatabase   "         # import data CD $install _home /sql/mysql/install    MySQL -uroot-p$password << EOF source 00_create_user.sql;    Use app; SOURCE 01_app_install.sql; Eofecho    end create MySQL Userdatabase    

Shell Common operations

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.