First upload the packaged JAR package to the server
1. Run Jar
java -jar xxx.jar
Terminate the jar operation mode:
1. ctr+c
2. You can stop the jar by closing the window
2. Run Jar in the background
java -jar xxx.jar &
& Stands for background operation.
Terminate the jar operation mode:
1. Close the window
2. Terminate the jar program by command (the method at the end of the article)
3. Run in the background and print the log to the default file
nohup java -jar xxx.jar &
Nohup represents the program running in the background, and the program log will be output to the nohup.out file in the current directory.
Terminating the jar operation mode:
1. Terminate the jar program by command (the method at the end of the article)
4. Run in the background and print the log to the specified file
nohup java -jar xxx.jar >./logs.txt &
>./logs.txt specifies that the program log is output to the ./logs.txt file.
Terminate the jar operation mode:
1. Terminate the jar program operation through the command (the method at the end of the article)
5. Terminate the jar program by command
First check the jar package process:
ps aux|grep xxx.jar
You will see the process information of this jar
data 5796 0.0 0.0 112656 996 pts/1 S+ 09:11 0:00 grep --color=auto getCimiss-surf.jar
data 30768 6.3 0.4 35468508 576800? Sl 09:09 0:08 java -jar getCimiss-surf.jar
Among them, 30768 is the pid of this jar, the kill command is: kill -9 30768 (kill -9 xxx ends the process whose process id is xxx)