Register the custom jar package as the linux service and centos7jar on centos 7.

Source: Internet
Author: User

Register the custom jar package as the linux service and centos7jar on centos 7.

On CentOS7, register the custom jar package as the linux service service1 and run the/etc/rc. d/init. create a shell script file named joyupx: vim joyupx/etc/rc. d/init. d/The Directory generally stores shell script files, but the file name cannot contain the suffix ". sh "; the service name must be/etc/rc. d/init. the name of the associated configuration file under the d/directory is identical; otherwise, such a service cannot be found; 2. Add the following code to the joyupx file :#! /Bin/bash # level # chkconfig: 2345 80 90 # description: joyupx service # process name # processname: joyupx-service # directory of the jar package ROOT_PATH =/usr/local/services/tomcat/apache-tomcat-9.0.0.M9/webapps # JDK root directory JAVA_HOME =/usr/local/services/jdk /jdk1.8.0 _ 91 PATH = $ PATH: $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin # CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar # CLASSES =$ {CLASSPATH}:/usr/work/space1/bin # e Xport JAVA_HOME # export PATH # export CLASSPATH # source function library #. /etc/rc. d/init. d/functionsstart () {echo-n $ "Starting $ prog: "# java-jar/usr/local/services/tomcat/apache-tomcat-9.0.0.M9/webapps/joyupx-service-jar-with-dependencies.jar java-jar $ ROOT_PATH/joyupx-service-jar-with-dependencies.jar # java-jar *. jar & echo "joyupx service" # java-version # echo "CLASSPATH :$ {CLASSPATH}" # ec Ho "PATH: $ {PATH}" # java-classpath $ CLASSES MyFrame #/usr/work/space1/bin/MyFrame start} stop () {echo-n $ "Stopping $ prog:" javac-version # java-jar/usr/local/services/tomcat/apache-tomcat-9.0.0.M9/webapps/joyupx-service-jar-with-dependencies.jar} restart () {echo-n $ "Reloading $ prog:"} case "$1" in start) start; stop) stop; restart) restart; *) echo $ "Usage: $0 {start | stop | restart} "RETVAL = 1 esac Exit $ RETVAL save and exit: ESC: wq! 3. Grant executable permissions to joyupx: chmod a + x joyupx4, start joyupx service: service joyupx start5, and view joyupx processes: ps-aux | grep joyupx

  

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.