Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy jar package project with Shell script in Linux

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use Shell scripts to deploy jar package projects in Linux, I believe most people do not know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's learn about it together.

one。 Install JDK

Check the number of operating digits of the computer: uname-ar

2017 x86_64 x86_64 x86_64 GNU/Linux

If 64-bit is shown here, download the corresponding 64-bit package

Let's start the formal installation of jdk

1. Upload the installation package of jdk to / root

Jdk-8u131-linux-x64.tar.gz

2. Confirm whether jdk has been installed on the system.

Rpm-qa | grep jdkrpm-e-- nodeps software name / / execute the uninstall command if an installation is detected

3. Extract the installation package of jdk to the specified directory

Tar-xvf jdk-8u131-linux-x64.tar.gz-C / usr/local/

4. Enter the decompressed directory

Cd / usr/local

5. Modify the folder name of jdk

Mv jdk1.8.0_131 jdk

6. Configure environment variables

Modify the environment variable configuration file:

Vi / etc/profile

Click I to enter edit mode

Jump to the last line and add the following. Note that the jdk here is the same as the path where you installed jdk.

# java runtime setingexport JAVA_HOME=/usr/local/jdkexport CLASSPATH=$JAVA_HOME/lib:.export PATH=$JAVA_HOME/bin:$PATH

Press ESC to enter: wq save exit

7. Reload the environment configuration

Source / etc/profile

8. Test whether the JDK installation is ok.

Java-version

9. Write hello.java

Vi Hello.java

Class Hello {public static void main (String [] args) {System.out.println ("hello,java");}}

Then ESC: wq exits

Vi / etc/profile I writing

Javac Hello.java

two。 Deploy the jar package

1. Create the data, and then create the test directory, and set up the related folders and files according to the following structure

The structure of the directory is:

The main jar packages, such as myjar, are placed under app. Here are the contents of the related restart.sh:

#! / bin/bashbase_home='/data/test'app_name='myjar'pid= `ps-ef | grep ${app_name} | grep-v grep | grep-v restart | awk'{print$2} '`if [- n "${pid}"] Then kill-9 ${pid} sleep 10figclog_file=$base_home/log/gc.logdump_dir=$base_home/heapdumperrorlogs_dir=$base_home/logjava-Xmx1g-Xms1g-XX:+UseParallelGC-XX:+UseParallelOldGC-XX:+PrintGCDetails-XX:+PrintGCTimeStamps-XX:+UseGCLogFileRotation-XX:GCLogFileSize=128M-XX:NumberOfGCLogFiles=1-Xloggc:$ {gclog_file}-XX:HeapDumpPath=$ {dump_dir}-jar $base_home/app/$ {app_name} .jar-spring.config.location=$base_home/config/application.yml > > $base_home/ Log/$ {app_name} _ $(date +'% Y% m% d'). Log &

What needs to be noted here is that

{app_name} .jar this may package the following error:

Error: Unable to access jarfile / app/myjar.jar

You may need to change to an absolute path here, as follows:

/ datat/test/app/$ {app_name} .jar

Access the relevant path: (modify it here according to the relevant port of your jar

Http://ip:8080/

View the path to the log:

Cd / log

The following shows the name and date of the relevant jar package in the log file such as: myjar_20190530.log

These are all the contents of the article "how to deploy jar package projects with Shell scripts in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report