Running jar files in background in ssh window
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.
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
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:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
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.
- Data Science
- Android
- React Native
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
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
Comments