Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When using rsync+ssh to access a remote machine, is there a way to "nice" the rsync process on the remote machine (to lower its priority)?

Editing the question to clarify:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
backups  16651 86.2  0.1   3576  1636 ?        Rs   11:06   0:06 rsync --ser...

(rsync line snipped)

This is a backup cron job that normally runs at 4am, but when I happen to be awake (and committing, or using Bugzilla hosted on that same machine), it kills server performance, so I wanted a quick "hack" to try and fix it a bit.

share|improve this question
add comment

5 Answers 5

up vote 21 down vote accepted

You can use the --rsync-path option, eg.

rsync --rsync-path="nice rsync" foo remotebox:/tmp/
share|improve this answer
7  
You might consider using ionice as well, e.g. --rsync-path="ionice -c 3 nice rsync", though modern Linuxes automatically reduce the IO priority for nice'd processes (see the man page I linked). –  Jo Liss Jun 23 '11 at 12:57
add comment

Rsync should not be using much CPU. I doubt that you can force a certain niceness from the other end, but what you could do is limit the bandwidth that rsync is using with a firewall, which would ultimately reduce how much processing it could do in X amount of time.

share|improve this answer
    
Added some output from 'ps aux' to show what it is doing as far as CPU. I'm going over a slow link, so I have the --compress option turned on, but it is also causing a good amount of disk access, which I was hoping to knock down by using nice (unintended side effect) –  mwalling Aug 18 '09 at 15:11
    
Setting a nice value usually also affects the I/O niceness, which is what someone usually wants. –  Bram Schoenmakers Aug 24 '10 at 7:46
add comment

I don't think so, you need a custom solution for that.. use ftp

share|improve this answer
4  
You know, that is a good idea. Who needs all of the features of rsync like being able to run over ssh with out needing a daemon running on the remote machine (and the inherent encryption of ssh), transfer compression, resuming downloads, only transferring the differences... thats all feature bloat. I'm going to run home right now and use my PS/2 System 60 to FTP some anime! –  mwalling Aug 18 '09 at 15:24
add comment

Quick and dirty solution would be to create a small wrapper script called 'rsync' that shadows the $PATH before real rsync binary like:

#!/bin/sh
nice -10 /path/to/proper/rsync $*

Or setup the authorized_keys file so that it performs nicing of rsync. (Assuming you are using ssh keys).

example:

command=”/home/user/bin/nice-rsync.sh" ssh-dss asdf....

Now in your /home/user/bin/nice-rsync.sh

#!/bin/sh
case $SSH_ORIGINAL_COMMAND in
  rsync\ --server*)
    nice -10 $SSH_ORIGINAL_COMMAND
    ;;
  *)
    $SSH_ORIGINAL_COMMAND
    ;;
esac

HTH

share|improve this answer
add comment

You could disable the compression along the network, by not including the -z argument, that might save some CPU time on either side. Or change how rsync uses checksums, look at --checksum

share|improve this answer
    
I accepted Hasturkun's answer (since it answered my question), but you brought up a good point: I benchmarked with compression vs without compression, and it only added 2 minutes to the job. I just got so used to using -avz as my flags that I never thought of dropping -z. –  mwalling Aug 18 '09 at 15:35
    
My habit is to use -aPh, I rarely use -z –  Rory Aug 18 '09 at 15:57
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.