Does quitting putty close the running command
I was using rsync to copy 15GB files between servers using putty. I want to know 开发者_如何学JAVAthat if i close putty terminal does that also termiates rync or not because file is not copied properly.
I have tried that when i am doing backups then even if i close putty then scrip continue to run in background
Assuming your goal is to have the rsync command continue to run, the simplest thing is to orphan the job. There are two ways to do this:
(rsync foo bar &)
The above will create the job detached from your terminal in the beginning, so closing the terminal will not stop it.
rsync foo bar & # or without &, then Ctrl-Z to stop, then "bg" to background
disown
The above will disown a running job, so you can close the terminal without stopping it.
Finally, you could use the program screen(1)
or similar to keep a terminal session alive and intact (and able to be resumed) even when you end your Putty session.
I'd advocate performing long operations such as rsync
ing 15GB across a network (or more pertinent to StackOverflow and programming, performing a large build on a remote host) within a GNU Screen session.
Then you can disconnect from the session (by closing PuTTY, if you like) and reconnect later to see how your job is progressing.
Update some time later...
These days I use and recommend tmux over gnu-screen.
Generally most command will quit if the console is closed. If you want them to keep running look at the NOHUP command (Nohup is No Hang Up Process, a hang over from the days of modems and 'hanging up' the phone)
Assuming you are running a rsync on some client the normal behaviour of a process is to terminate if it was loosing its controlling tty which is the case when you close putty. You may however run jobs with nohup (NOHUP(1)), and i guess that is what your backup scripts are doing (if no other "tricks" were involved). The output of your rsync commadn will then be appended to a file nohup.out in the current or your home directory depending on your permissions on the machine the nohup process is running on.
Reason:
When you execute a Unix job in the background ( using &, bg command), and logout from the session, your process will get killed(Hang Up).
Two solutions:
1./ Nohup, which stands for no hang up, which can be executed as shown below.
nohup syntax:
# nohup command-with-options &
2./
(command-with-options &)
精彩评论