LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Copy file in background (https://www.linuxquestions.org/questions/linux-newbie-8/copy-file-in-background-4175476826/)

sluge 09-12-2013 03:34 AM

Copy file in background
 
Hello!
I connected to the server1 via ssh from my workstation and start coping file using scp from server1 to server2. I need to logoff from my workstation but I don't want to interrupt coping process because it takes a long time.
Is any way to run coping in background?

Firerat 09-12-2013 03:58 AM

my first offering is use screen

you do not mention which Linux Distro you use, so I can not advise how you install it

open a 'screen'
Code:

screen
then your scp, optionally followed by && exit
Code:

scp file Server2 && exit
now detatch from screen with Ctrl+a ,d
that is Ctrl+a keycombo, then key d

you should now be able to logoff

when you log back on reattach to screen
Code:

screen -x
if that fails, all went well
if not either the upload is still in progress or something went wrong.. you should see any error that occurred.

jpollard 09-12-2013 05:12 AM

Use ctrl-Z and the bg command.

Bash by default does not abort background processes when logging out (I believe the cshell does).

pan64 09-12-2013 05:20 AM

nohup <your command> &
will do the job, in your case your command will be that scp. Dont forget to save output (in case of any error)

pan64 09-12-2013 05:22 AM

Quote:

Originally Posted by jpollard (Post 5026321)
Bash by default does not abort background processes when logging out (I believe the cshell does).

this is not true, you can decide if a child process will check the existence of its parent or will be detached. This does not depend on the type of the shell.

canadensis 09-12-2013 07:54 PM

An alternative to using screen is tmux (http://tmux.sourceforge.net/). Both are terminal multiplexers - allowing you to start a job, logoff, then return later.

Firerat 09-13-2013 01:49 AM

I will have to look at that canadensis, thanks... hoping it handles "scrollback" better than screen :)


All times are GMT -5. The time now is 02:30 AM.