LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-12-2013, 03:34 AM   #1
sluge
Member
 
Registered: Dec 2006
Location: Russia,52
Posts: 116

Rep: Reputation: 6
Question 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?
 
Old 09-12-2013, 03:58 AM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
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.

Last edited by Firerat; 09-12-2013 at 03:59 AM.
 
Old 09-12-2013, 05:12 AM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,602

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Use ctrl-Z and the bg command.

Bash by default does not abort background processes when logging out (I believe the cshell does).
 
Old 09-12-2013, 05:20 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
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)
 
1 members found this post helpful.
Old 09-12-2013, 05:22 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
Quote:
Originally Posted by jpollard View Post
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.
 
Old 09-12-2013, 07:54 PM   #6
canadensis
Member
 
Registered: Sep 2013
Location: Sydney, Australia
Distribution: Slackware, xBSD, Manjaro-OpenRC
Posts: 50

Rep: Reputation: 5
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.
 
2 members found this post helpful.
Old 09-13-2013, 01:49 AM   #7
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

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


Reply

Tags
copy, file


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nautilus file manager List file background problem rng Linux - General 5 08-22-2012 08:22 PM
I want to run php file in background on fedora terminal in background. gauravwcities Linux - Newbie 8 01-18-2012 01:23 AM
[SOLVED] Script to copy paste text from one file to another (overwriting part of the file) freet Programming 4 04-19-2011 04:23 PM
copy last 10000+ lines of large text file to a temporary file emilyg Linux - Newbie 3 06-24-2009 03:43 PM
Is arrangement of file systems will differ if we copy a file from FAT 32 to ext 3 ? anindyanuri Linux - Software 2 02-20-2005 12:39 PM


All times are GMT -5. The time now is 02:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration