4

Possible Duplicate:
Leave bash script running on remote terminal while not logged in?

Recently, I tried to unzip a 30 gig zip file on a remote system using Putty. As the long unzipping process continued, I closed Putty, assuming that the process would just continue to run on the remote machine.

When I came back later and logged back into the machine again, I realized that the process must have stopped only part way through when I closed Putty. I wasn't expecting that to happen.

My question is, how do I prevent this problem? Can I somehow fire off a process in the background? Or should just setup a one time cronjob that will run the process for me?

Jake Wilson
  • 4,314
  • 10
  • 38
  • 39
  • 3
    This question has been answered before, see e.g. http://superuser.com/questions/111631/leave-bash-script-running-on-remote-terminal-while-not-logged-in or http://superuser.com/questions/8673/how-can-i-use-ssh-to-run-a-command-on-a-remote-unix-machine-and-exit-before-the-c – akid Apr 04 '10 at 16:57
  • there's also http://superuser.com/questions/106946/how-to-run-a-bash-script-outside-of-a-terminal and http://superuser.com/questions/124399/keep-a-program-running-after-closing-a-console-after-the-program-has-started but i think [akid's first link](http://superuser.com/questions/111631/leave-bash-script-running-on-remote-terminal-while-not-logged-in) is the closest match with the most direct answer. – quack quixote Apr 04 '10 at 17:24

2 Answers2

7

nohup or disown (in bash) will allow a process or job to continue in the background after the controlling shell has been killed.

Ignacio Vazquez-Abrams
  • 111,361
  • 10
  • 201
  • 247
3

You could use gnu screen to run the program, and then re-attach to the session later. Just start screen, then start the unzip process. When you want to disconnect, press Ctrl-A D. Then when you want to re-attach to the screen session use screen -r and it'll re-attach to the previous session.

Jonathan Heady
  • 3,671
  • 22
  • 16