Join to Get Free Linux Server Hacks & cPanel Tips

How to run Rsync process in background

How to run Rsync process in background
4.6 (91.11%) 18 votes

Question: how can I run rsync process in background?
Answer: rsync can be run in background by using the nohup command in front of it, and & at the end. Let’s explore how to run this command as background process in Linux.

Why would I need to run rsync process in Background ?

Well, I’m pretty sure that this has happened to you, or will happen soon. You are running an important process to copy data from one server to another, then suddendly internet connections goes off, or you forgot you were running that command and just logout from the session.

The result: your rsync, scp or other process will be terminated, and your work unfinished. What can do you to avoid starting your rsync process again?

The solution to keep rsync running in background

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

The solution is simple: we will use the nohup command. 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:

[root@host.nixcp.com:~]nohup rsync -avp -e 'ssh -p 12141' root@111.111.111.111:/home/user/public_html/files/2015 /root/temp/public_html/files/ &
[1] 33376
[root@host.nixcp.com:~]

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.

References: