Mirage
Mirage

Reputation: 31568

Running rsync in background

I use this to run rsync in background

rsync -avh /home/abc/abac /backups/ddd &

When i do that i see line saying 1 process stopped.

Now does that mean my process is still running ot it is stopped

Upvotes: 14

Views: 115916

Answers (7)

Jinna Baalu
Jinna Baalu

Reputation: 7839

The solution to keep rsync running in background

nohup rsync -a host.origin:/path/data destiny.host:/path/ &

Nohup allows to run a process/command or shell script to continue working in the background even if you close the terminal session.

In our example, we also added ‘&’ at the end, that helps to send the process to background.

Output example:

 nohup rsync -avp [email protected]:/root/backup/uploads/ . &

 [1] 33376
 nohup: ignoring input and appending output to 'nohup.out'

That’s all, now your rsync process will run in the background, no matter what happens it will be there unless you kill the process from command line, but it will not be interrupted if you close your linux terminal, or if you logout from the server.

RSync Status

cat nohup.out

Upvotes: 28

CADENTIC
CADENTIC

Reputation: 55

File Transfer:

nohup scp oracle@<your_ip>:/backup_location/backup/file.txt . > nohup.out 2>&1 &

then hit ctrl-z

$ bg

To bring the command alive

Upvotes: 0

Michael
Michael

Reputation: 11

This is safe, you can monitor nohup.out to see the progress.

nohup rsync -avrt --exclude 'i386*' --exclude 'debug' rsync://mirrors.kernel.org/centos/6/os . & 

Upvotes: 1

niofox
niofox

Reputation: 397

When you press "ctrl + z" then the process stopped and go to background.

[1]+ Stopped rsync -ar --partial /home/webup/ /mnt/backup/

Now press "bg" and will start in background the previous process you stopped.

[1]+ rsync -ar --partial /home/webup/ /mnt/backup/ &

Press "jobs" to see the process is running

[1]+ Running rsync -ar --partial /home/webup/ /mnt/backup/ &

If you want to to go in foreground press "fg 1" 1 is the process number

Upvotes: 34

KARASZI Istv&#225;n
KARASZI Istv&#225;n

Reputation: 31477

No, it means it has been stopped.

You can check it with jobs.

Example output:

jobs
[1]+  Stopped                 yes

Then you can reactivate with fg, example:

fg 1

Upvotes: 3

Hyperboreus
Hyperboreus

Reputation: 32459

If everything works, your call should return you the PID of the new progress and some time later a "Done" message.

So yeah, your output looks like your process is not running.

Check ps to see if rsync is running.

Upvotes: -1

Nemo
Nemo

Reputation: 71615

It is probably trying to read from the terminal (to ask you for a password, perhaps). When a background process tries to read from the terminal, it gets stopped.

You can make the error go away by redirecting stdin from /dev/null:

rsync -avh /home/abc/abac /backups/ddd < /dev/null &

...but then it will probably fail because it will not be able to read whatever it was trying to read.

Upvotes: 6

Related Questions