scp as a background process

To execute any linux command in background we use nohup as follows:

$ nohup SOME_COMMAND &

But the problem with scp command is that it prompts for the password (if password authentication is used). So to make scp execute as a background process do this:

$ nohup scp file_to_copy user@server:/path/to/copy/the/file > nohup.out 2>&1

Then press ctrl + z which will temporarily suspend the command, then enter the command:

$ bg

This will start executing the command in backgroud

Advertisement

Tags: ,

12 Responses to “scp as a background process”

  1. viktor says :

    Hi man,

    I’d like to thank you for your greate help regarding scp with password authentication vs. background copying!!

    Viktor

  2. c says :

    At what point do we enter the password? Thanks for the help.

  3. kunalbharati says :

    @c: After you enter the command it should ask you for password.
    For eg:

    $ nohup scp file_to_copy user@server:/path/to/copy/the/file > nohup.out 2>&1

    After this command it should prompt you for password.

  4. Lauro says :

    very good !!!!!!

  5. vtypal says :

    I offer you a beer, man. !!! Great. !!!

  6. mpc755 says :

    Exactly what I was looking for. Thanks.

  7. Sachin says :

    Thanx, that was a great help

    sachin

  8. Abc says :

    thnx

  9. Tohir Solomons says :

    Super!! Just the info I needed. Thanks for Sharing!

  10. erikig says :

    If you have more that one job running you can run jobs to see the status

    $ jobs
    $ %job_number_1
    $ %job_number_2
    $ %job_number_3
    $ %job_number_4

    You can run bg %job_number or fg %job_number to swap jobs to the background or foreground

    $ bg %job_number

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.