Hi all i want to run a java application as backend process.that is like tomcat server.For that i had developed one application.and made one class as main class and calling from one script file .i.e(startup.sh) file.in startup.sh file i was calling one class.that is MainMethodClass.In main method class i had written my business logic.when i am running this app in linux server from using putty is is working until putty window is not closed.As closed after putty window it is also stopped.but i need to run this app even i closed also.How can i achieve this.
Asked
Active
Viewed 4.4k times
12
-
possible duplicate of [command execution with nohup in background](http://stackoverflow.com/questions/7519539/command-execution-with-nohup-in-background) – Synesso Feb 17 '12 at 06:09
4 Answers
45
Nohup will detach a process you run from your current console and let it continue when you close the terminal. Run something like this.
nohup java -jar my.jar &
By default it will pipe the output to nohup.out, so if you don't want that you could try:
nohup java -jar my.jar > /dev/null &

cutchin
- 1,177
- 1
- 8
- 12
-
1I want to run following command "java -jar myApp.jar arg1 &", it causes the nohup: ignoring input and appending output to `nohup.out'. what should I do in order to run the command with input argument? – E A Apr 05 '16 at 11:29
6
This problem is not related to java, its actually something related to the way linux operates.
You need to do following:
nohup <your_application_command> &
Note the "nohup" and "&" at start and end respectively.

Manish
- 3,913
- 2
- 29
- 45
-
thank you all for your quick responses it is working with sh startup.sh & and i made changes after calling class file i.e MainMethodClass & it is working without interruption.once again thanks to all. – java tech Feb 17 '12 at 07:28
3
You should be able to do something like:
nohup java -jar MyApplication.jar &

mikera
- 105,238
- 25
- 256
- 415
1
On a linux machine you can create a service for your jar( executable jar like spring boot )
# Set the Application as Service
ln -s $APP_BASE/bin/$APP_NAME.jar /etc/init.d/$APP_NAME
echo "Starting the application as service"
service $APP_NAME start