Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 959
Mirage Avatar asked May 26 '11 16:05

Mirage


People also ask

Can we run rsync in background?

The solution to keep rsync running in backgroundNohup 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.

How do I run rsync in daemon mode?

There are two different approaches to have rsync running as a daemon, one is to launch the program with the --daemon parameter, and the other is to have inetd or xinetd to launch rsync and have it running as the other services that inetd and xinetd handles. But first, we must configure the file /etc/rsyncd.

How do I run a copy of a background in Linux?

Use bg to Send Running Commands to the Background You can easily send such commands to the background by hitting the Ctrl + Z keys and then using the bg command. Hitting Ctrl + Z stops the running process, and bg takes it to the background. You can view a list of all background tasks by typing jobs in the terminal.


2 Answers

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

like image 114
niofox Avatar answered Oct 07 '22 02:10

niofox


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
like image 36
Jinna Balu Avatar answered Oct 07 '22 01:10

Jinna Balu