Linux runs the jar package command as follows:
method one:
java -jar shareniu.jar
Features: The current ssh window is locked, you can press CTRL + C to interrupt the program running, or directly close the window, the program exits
How to make the window not locked?
Way two
java -jar shareniu.jar &
& Stands for running in the background.
Specific: The current ssh window is not locked, but when the window is closed, the program stops running.
Continue to improve, how to make the program still run when the window is closed?
Way three
nohup java -jar shareniu.jar &
nohup means to run the command without hanging up. When the account is exited or the terminal is closed, the program still runs
When a job is executed with the nohup command, all output of the job is redirected to the nohup.out file by default, unless an output file is specified otherwise.
Way Four
nohup java -jar shareniu.jar >temp.txt &
Explanation>temp.txt
command >out.file
command >out.file redirects the output of the command to the out.file file, that is, the output content is not printed on the screen, but output to the out.file file.
You can view background running tasks through the jobs command
jobs
Then all the jobs executed in the background will be listed, and each job has a number in front of it.
If you want to return a job to the foreground control, you only need fg + number.
fg 23
View the pid of the thread occupied by a port
netstat -nlp | grep: 9181
If you forget the process number, you can use the following command to view the process number of the currently running jar package program
ps -ef|grep xxx.jar
Or ps -aux | grep java
//Close the process
kill -s 9 24204
24204 represents the process ID found in the previous step