By: Sachi in Linux Tutorials on 2012年07月15日 [フレーム]
When you need to run a java application in the background in unix, you can use the screen command. When you run the screen command in your ssh window, even after you close the window, your application will still run. In fact this will work for any application not only java application.
screen -A -m -d -S trackapps java -jar putyourjarfilenamehere.jar
The command "screen -A -m -d -S trackapps java -jar putyourjarfilenamehere.jar" does the following:
"screen" is a command in Linux/Unix systems that allows users to create and manage multiple terminal sessions within a single console window. By using the "screen" command, we can run the specified command in a detached background session, which allows the command to continue running even after we log out or close the terminal window.
"-A" tells screen to adapt the terminal's size to the size of the client's display.
"-m" tells screen to create a new window if there are no existing screens to attach to.
"-d" tells screen to detach the terminal from the current session after it is created.
"-S trackapps" tells screen to create a new session with the name "trackapps".
"java -jar putyourjarfilenamehere.jar" is the actual command that we want to run in the detached screen session. This command runs a Java program (the one specified by the JAR file name) using the "java" executable.
So, in summary, the command "screen -A -m -d -S trackapps java -jar putyourjarfilenamehere.jar" creates a detached screen session named "trackapps" and runs a Java program specified by the JAR file name in that session. This allows the program to continue running in the background even after the user logs out or closes the terminal window.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in Linux )
make: Nothing to be done for `all'.
Running jar files in background in ssh window
How to burn your CD / DVD ISO image using Nero Burning ROM (Ahead Software) on Windows
smskannel SMS gateway run in background
Can't locate ExtUtils/MakeMaker.pm in @INC ...
Could not open '': No such file or directory at lib/ExtUtils/MM_Unix.pm line 2697
Install and configure Memcached in linux
How to burn your CD / DVD ISO image using Media Creator (Adaptec/Roxio) on Windows
How to burn your CD / DVD ISO image using Nero Express (Ahead Software) on Windows
Latest Articles (in Linux)
smskannel SMS gateway run in background
Running jar files in background in ssh window
Install and configure Memcached in linux
Can't locate ExtUtils/MakeMaker.pm in @INC ...
Could not open '': No such file or directory at lib/ExtUtils/MM_Unix.pm line 2697
make: Nothing to be done for `all'.
How to burn your CD / DVD ISO image using Nero Burning ROM (Ahead Software) on Windows
How to burn your CD / DVD ISO image using Media Creator (Adaptec/Roxio) on Windows
How to burn your CD / DVD ISO image using Nero Express (Ahead Software) on Windows
How to burn your CD / DVD ISO image using k3b on CentOS
smskannel SMS gateway run in background
Running jar files in background in ssh window
Install and configure Memcached in linux
Can't locate ExtUtils/MakeMaker.pm in @INC ...
Could not open '': No such file or directory at lib/ExtUtils/MM_Unix.pm line 2697
make: Nothing to be done for `all'.
How to burn your CD / DVD ISO image using Nero Burning ROM (Ahead Software) on Windows
How to burn your CD / DVD ISO image using Media Creator (Adaptec/Roxio) on Windows
How to burn your CD / DVD ISO image using Nero Express (Ahead Software) on Windows
How to burn your CD / DVD ISO image using k3b on CentOS
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate