LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-11-2011, 01:29 PM   #1
khanahmedabbas
LQ Newbie
 
Registered: Nov 2011
Posts: 11

Rep: Reputation: Disabled
Smile How to run scp in background after logging out session ?


Hello,

I am trying to transfer files from old remote server to new remote server using scp command

The scp command which works for me is

scp -r root@ipaddress:/home/admin/www www

It ask me for password and i enter password and it starts uploading files from old remote server to new remote server which i can see but i have files over 45gb so i don't want to see each and every file transferring by looking at putty.

I heard scp can run in background so after exiting session from new server or exiting putty the background works.

What i did to work scp command in background is :

scp -r root@ipaddress:/home/admin/www www

after the upload starts cntrl + Z then type [bg] it runs in background which i can see by typing [jobs] then i type [exit] and putty closes then i relogged in again to new server from where i use scp command to see if my job in background is running by typing [jobs] but it didn't show any background processing jobs.

What shall i do ? What am i missing ?

Please suggest me immediately.
 
Old 12-11-2011, 03:44 PM   #2
davemguru
Member
 
Registered: Apr 2006
Location: London
Distribution: Pclos,Debian,Puppy,Fedora
Posts: 87

Rep: Reputation: 42
Perhaps you should look at
Code:
nohup
command.
Place the command/s that you wish to be executed in a script - let's call it "xx". Mark the script as executable. Then
Code:
 nohup ./xx &
Note the ampersand (&) to place the command in the background.
Now when you logout - the "hangup signal SIGHUP" will be ignored by all of the commands running beneath nohup.
As a "bonus" - you can return later and examine any of the output by viewing "nohup.out".

Dave
 
Old 12-11-2011, 03:46 PM   #3
khanahmedabbas
LQ Newbie
 
Registered: Nov 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
i am complete newbie in ssh can you please post steps like after entering into ssh mode what i must do ?

like scp -r root@ipaddress:/home/admin/www www then cntrl z or ....etc please post step by step.
 
Old 12-11-2011, 03:59 PM   #4
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
just like "davemguru" wrote
Code:
# nohup scp -r root@ipaddress:/home/admin/www www &
then the process will run in background and it will not terminate if you logout of your session.

Try run something that will do something for at least some time, it's the same way like:
Code:
# nohup tar czvf /var/tmp/some_test_file.tar.gz /etc &
and logout and relogin and check if it's still running.

good luck

Last edited by lithos; 12-11-2011 at 04:00 PM.
 
Old 12-12-2011, 04:56 AM   #5
khanahmedabbas
LQ Newbie
 
Registered: Nov 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
ok i posted this command in ssh

Quote:
nohup scp -r root@ipaddress:/home/admin/www www &
and it said

Quote:
nohup scp -r root@ipaddress:/home/admin/www www &
[1] 23794
[sasin]$ nohup: ignoring input and appending output to `nohup.out'
nohup is not working i think as i typed "jobs" and it showed nothing.

What shall i do ? i can provide you teamviewer id and pass to check from my computer.
 
Old 12-12-2011, 05:02 AM   #6
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Then use screen
.
 
Old 12-12-2011, 05:05 AM   #7
khanahmedabbas
LQ Newbie
 
Registered: Nov 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
lithos i am new can you please login to my computer using teamviewer and do it from ssh ? please dear.....

you can private message me your messenger id and i will message you there.

Thankyou so much.
 
Old 12-12-2011, 05:13 AM   #8
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by khanahmedabbas View Post
you can private message me your messenger id and i will message you there.
This forum doesn't work like that. What problem do you have using Screen? There's a tutorial here that might be useful to you.
 
Old 12-12-2011, 05:16 AM   #9
khanahmedabbas
LQ Newbie
 
Registered: Nov 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
after reading tutorial i am unable to understand, please you just have to run a scp command which works in background so after closing ssh it works.

Last edited by khanahmedabbas; 12-12-2011 at 08:49 AM.
 
0 members found this post helpful.
Old 12-12-2011, 05:22 AM   #10
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Again, this forum doesn't work like that. I suggest you remove your email addresses, unless you want spam (not from LQ members, but from bots that will harvest them).

Again, what exactly is the problem using Screen? You just run "screen" at the terminal, then run your scp command and use "Ctrl-a d" to detach the Screen session and you can log out. When you log in, you can run "screen -r" to reattach the session.
 
Old 12-12-2011, 05:24 AM   #11
khanahmedabbas
LQ Newbie
 
Registered: Nov 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
sure i will remove my email address after few minutes after lithos messages me, nylex why dont you please show me how it can be done on my computer.

i am online its just running scp command in background.

Thankyou.
 
Old 12-12-2011, 05:24 AM   #12
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
I've just shown you how to do it, so I don't understand what the problem is.
 
Old 12-12-2011, 05:27 AM   #13
khanahmedabbas
LQ Newbie
 
Registered: Nov 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
i am newbie in ssh, i have come to linuxquestions to receive support from linux addicts. Please its matter of only running scp command in background can you please login to my computer using teamviewer and put the command to work....please.
 
Old 12-12-2011, 05:42 AM   #14
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
I'm not going to log into your machine and I don't think you'll find others to do that, either. What is the problem with doing this yourself?
 
Old 12-12-2011, 05:44 AM   #15
khanahmedabbas
LQ Newbie
 
Registered: Nov 2011
Posts: 11

Original Poster
Rep: Reputation: Disabled
i dont want any of the files to be deleted or something wierd happened to server.

i can pay anyone $5 through paypal who completes this project after the work is completed and i am not joking. If you trust you can message me.
 
  


Reply


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wget and scp in background nima0102 Linux - Server 3 05-12-2009 09:09 AM
Make SCP run in background? Moonman Linux - Software 3 11-29-2007 07:46 AM
SCP as a background process Edmunds Linux - General 4 12-31-2006 12:20 PM
Run in the background even after logging off rust8y Linux - Newbie 13 05-19-2006 06:38 AM
How to run a program in an ssh session that will run after you close out the session? dr_zayus69 Linux - Networking 5 03-05-2006 07:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:04 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
Open Source Consulting | Domain Registration