Scripting of Java projects running under Linux system

Source: Internet
Author: User

This article mainly describes the Linux system running the jar package, as to how to package the jar, put into the Linux system can refer to other blogs.

The command to run the jar package under the Linux system is as follows:

1, Java-jar Xxxxx.jar//The current SSH window is locked, you can press CTRL + C to interrupt the program to run, or directly close the window, the program exits

2, Java-jar Xxxxx.jar &//The current SSH window is not locked, but when the window is closed, the program stops running.

3. Nohup Java-jar Xxxxxx.jar &/means not to hang up the Run command, when the account exits or the terminal shuts down, the program still runs

Just deploy it once, then actually run it and you'll find the problem and then search for it yourself. So how to write a shell script, directly run the resart.sh script is good.

After several trials, it was finally written. as follows: restart.sh

Pid= ' Ps-ef | grep rulecc-1.0.0 | grep-v grep |awk ' {print $} ' if [$pid]; Then      Echo:app  is  running pid= $pid    kill-9 $pidfinohup java-jar/apps/rulecc-1.0.0/ Rulecc-0.0.1-snapshot.jar &tail-f Nohup.out

 

For some Daniel will soon be able to understand, if you like me, a little bit of Linux Script Foundation and experience is not, then the following knowledge and operations can help you understand:

1. After running a Java program in a Linux environment, how can I view the thread that started the program? How do I close a thread that runs a program?

Step one: Enter the command under the path to run the app: JPS

The second step: when you find the corresponding app, then you will be able to find the corresponding thread, no find and no relationship, to search the Internet, or ask people who have written around, can also find. Assuming the pid=12522 of the target thread

Step three: "Kill" the thread running the app: Kill-9 12522

Fourth step: Re-run the Java program.

Fifth step: Repeat the previous four steps. Do it a few more times and you'll know what it means.

Here's an explanation of what the restart.sh script means:

First line: Assign the thread PID of the running target to the PID variable

Second line: Determine whether the PID is running

Third line: If the PID that runs on the print run

Line four: "Kill" the PID of the Run

Line five: Run the Java program.

Line Six: Check it yourself.

Problem: In writing restart.sh encountered a few problems, have been successfully resolved, to provide reference, if there is no solution to the question, welcome message.

1. xxx.sh script run is not allowed.

2, syntax error near unexpected token. This problem occurs because the line breaks in the Windows environment are not recognized in the Linux environment, so it is converted into a Linux environment.

This in Baidu experience will have, here will not wordy.

===============================

Here are some running statements in common Linux environments:

Cd..           Go back to the top level directory Cd/apps//Open folder LS//view file CD./icreditrisk//Open a folder under the current folder LS//view file Vim Application.xml//view the file I           Insert, modify q! Discard changes Wq//Save changes

[Reference Article]

1, http://blog.csdn.net/wggorking/article/details/53925907

2, https://jingyan.baidu.com/article/9f63fb91d014b8c8410f0e7a.html

3, http://blog.csdn.net/catoop/article/details/50588851

4, http://blog.csdn.net/qq_30739519/article/details/51115075

Scripting of Java projects running under Linux system

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.