How I can retain my server on when my putty is closed
Hi Friends...
I have a server program in ubuntu which i run using putty remotely. My problem is that when i closes my putty window, my server automatically closes and stop working. I want that once i start my server it remains on when i closed my putty window. Please help... Any one... Thanks in advance |
Start it in a screen
http://www.gnu.org/software/screen/manual/screen.html Or use nohup Code:
nohup programname >/dev/null 2>&1 & |
i second screen, because you can detach a screen session before closing putty and then re-attach it later on, or re-attach the session from elsewhere if necessary
|
I would suggest to deamonize than using screen.
Screen has two problems. 1) Security. 2) If some one kill the session, it will kill the program as well. People not much bothered about what is running in screen, if there is a server hung. hup is one good way to run it. there is rc.local file in redhat to have customized programs running from the startup. You can find out the alternative of it in Ubuntu. |
Quote:
|
Quote:
Another option would be tmux: http://tmux.sourceforge.net/ However you can write a "proper" daemon that behaves as expected when you disconnect your terminal. This will require a little research on your part, but there is plenty of information on the web. Basically you need to fork twice, change the CWD to /, redirecting stdout/err/in to /dev/null and closing all non standard file descriptors etc. Cheers, Evo2. |
Quote:
Please explain it properly step by step Thanks again.... |
Quote:
|
Quote:
Cheers, Evo2. |
at the end of your command just add an ampersand symbol & it will run the process in the back ground...
so if your command was ./somescript & or tail -f log.txt > output.txt & the ampersand will run whatever command you have for as long as the program is set to run in the background uninterrupted.. http://www.go2linux.org/running-prog...the-background its a simple way of doing it |
Quote:
I write "java -jar Server.jar &". My swing window displays by which i start ther server on click "Start Server" button. Now server is start but on closing putty again server shuts automatically... |
a weird thought. Why don't you change it to start directly when you fire the command "java -jar Server.jar &" or Is there no option to accept start as a parameter .. "java -jar Server.jar start &"
"java -jar Server.jar start > $LOG_FILE 2>1 &" this could be a better way you can get the errors logged in the $LOG_FILE .. set the $LOG_FILE accordingly... |
Quote:
There is not option "java -jar Server.jar start". We have to click on "Start Server" button... Now what we should do??? okk Now I changed my program and server starts automatically on running "java -jar Server.jar &". After that I closed putty but problem is still same... what i should do explain clearly please..... |
Reply please
|
Quote:
It not works....Please come back |
All times are GMT -5. The time now is 04:29 PM. |