I am using putty to interact with Linux server. I have started a process using putty. The process is running and will take 5-6 hours. I want that process to keep running after I close the putty session. How can I keep that process alive after closing the putty session? I do not want to keep the computer ON all the time. Is there any way to do this?.
I use screen for that kind of stuff. Actually sometimes I just leave it on quite a while so I can get back to what I was doing.
^Z bg %1 disown -h %1
The '-h' makes the process immune to SIGHUP when the session completes.
nohup command. Just prefix it to your command and it will daemonise them so that they won't stop when you log off/terminate your shell session. The standard output will by default be in a file called nohup.out. Check the manual page for
nohup(1) for more information.
Start process with
nohup "processname" &.
You can also detach it with
The above solutions are quite well described, however, none of them worked for me UNTIL I also edited PuTTY configuration to :
Enable TCP keepalives (SO_KEEPALIVE option)
I hadn't seen this anywhere else, and just found it by trial and error.
Ctrl+z Send the current process to the background.
Also, you may add & at the end of your command to run in in background
If you want the program that is contained in the process to always or frequently run in the background, you can code it to separate from the controlling terminal (make such behaviour controllable via an option flag) and run in the background.
That's a long term solution, of course, not for the currently running process.
You can use
& after the link.
[localhost ~ ]# wget http://www.link.com/download/download.zip &
How to keep weblogic running after closing putty window:
Simple Steps: after the login through putty follow the below steps:
- Go to the directory on the server where the
startWebLogic.shcommand is located.
- Type command
screenand press Enter (a new screen will open).
- In the new screen type your run command
- Press Ctrl+a then press d (without holding Ctrl); you will return back to the previous screen.
- When you want to return to your server log screen, type command
if the process is a for nodejs, and it may be your intention since you originally posted this on stackoverflow. I was originally searching for this question myself. I found pm2 and it is amazing. The other answers may help for general putty but if it is node specific this is by far the best answer, as there is built in monitoring and the setup is simply a
$ npm install pm2 -g $ cd yourappdirectory
"PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
Starting an application in production mode is as easy as:"
$ pm2 start yourappname.js
"using the save and then freeze command you enable the processes to autostart on reboot"
$ pm2 save $ pm2 freeze
for monitoring its
$ pm2 monit
$ pm2 restart yourappname
also for direct logging information
$ pm2 logs
I now can easily run two putty windows instead of using my digialocean browser window (which I couldnt scroll up on); For more info see the main github