Source: https://www.cnblogs.com/zery/p/7799005.html
The command to run the jar package in Linux is 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 and the program exits
How can I keep the window from locking?
Method 2
- 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 aborts.
Continue to improve, how to make the program still run when the window is closed?
way three
nohup java -jar shareniu.jar &
nohup means do not hang up running the command, when the account is logged out or the terminal is closed, the program still runs
When a job is executed with the nohup command, by default all output from the job is redirected to the file nohup.out, unless an output file is specified otherwise.
way four
- nohup java -jar shareniu.jar >temp.txt &
Explain >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 to the screen, but is 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 are listed, and each job is preceded by a number.
If you want to call a job back to foreground control, you only need fg + number.
- fg 23
View the pid of the thread occupied by a port
netstat -nlp | grep: 9181