LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to run scp in background after logging out session ? (https://www.linuxquestions.org/questions/linux-general-1/how-to-run-scp-in-background-after-logging-out-session-918207/)

khanahmedabbas 12-11-2011 01:29 PM

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.

davemguru 12-11-2011 03:44 PM

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

khanahmedabbas 12-11-2011 03:46 PM

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.

lithos 12-11-2011 03:59 PM

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

khanahmedabbas 12-12-2011 04:56 AM

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.

lithos 12-12-2011 05:02 AM

Then use screen
.

khanahmedabbas 12-12-2011 05:05 AM

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.

Nylex 12-12-2011 05:13 AM

Quote:

Originally Posted by khanahmedabbas (Post 4547773)
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.

khanahmedabbas 12-12-2011 05:16 AM

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.

Nylex 12-12-2011 05:22 AM

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.

khanahmedabbas 12-12-2011 05:24 AM

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.

Nylex 12-12-2011 05:24 AM

I've just shown you how to do it, so I don't understand what the problem is.

khanahmedabbas 12-12-2011 05:27 AM

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.

Nylex 12-12-2011 05:42 AM

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?

khanahmedabbas 12-12-2011 05:44 AM

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.


All times are GMT -5. The time now is 12:47 PM.