Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I pause an rsync that's running?

First time I did Ctrl+C to kill it and used the -P flag to run again. Is this prone to corrupt the current file transfer?

Second time I simply put MacOS to sleep (by closing the lid). Looking at the running process I can see 2 (not sure why) with a status of 'S'.

Tried using

kill -SIGCONT

to resume the process, but it has no effect.

share|improve this question
add comment

3 Answers

up vote 20 down vote accepted

You can pause any program by sending it a TSTP (polite) or STOP (forcible) signal. On the terminal you've run rsync in, pressing Ctrl+Z sends TSTP. Resume with the fg or bg command in the terminal or a CONT signal.

It is safe to kill an rsync process and run the whole thing again; it will continue where it left off. It may be a little inefficient, particularly if you haven't passed --partial (included in -P), because rsync will check all files again and process the file it was interrupted on from scratch.

There may be unusual combinations of options that will lead to some files not being synchronized properly, maybe --inplace with something else, but I think no single option will cause this.

If you disconnect your laptop and reconnect it somewhere else, it may get a different IP address. Then the TCP connection used by rsync would be severed, so you'd have to kill it and start again. This can also happen if you suspend your laptop and the TCP connection times out. The timeout will eventually filter out to the application level, but it can take a while. It's safe to press Ctrl+C and run rsync again.

share|improve this answer
add comment

Ctrl + Z to suspend, and:

$ fg

to continue, use

$ jobs

to see suspended jobs; bg [number] to background them; fg [number] to foreground it.

Ctrl+S

can also be used to suspend; then Ctrl + q to continue it.

share|improve this answer
2  
Ctrl+S only suspends scrolling output, not the underlying program (unless it gets blocked waiting for the terminal to accept its output), and only if you haven't disabled it. –  Gilles Jan 16 '11 at 13:31
    
With the current 'S' status it doesn't resume. Is it safe to kill it using Ctrl+C and run rsync again? What other options do I have? Will have that in mind next time though, thanks. –  qnoid Jan 16 '11 at 13:32
    
Also note that Ctrl-Z to suspend a process is likely, after some time, to result in the timeout of any TCP network connections which were established by that program. Thus leaving an rsync suspended for more than a few minutes will very likely cause it to quit abruptly with an error message when you put it back in the foreground and it finds that its opened sockets are returning errors from reads and writes. –  Jim Dennis Jan 17 '11 at 14:18
add comment

Run rsync with the --partial flag. It will then keep partial transfers and resume partial files when started.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.