Is it possible to rate-limit an scp/sftp/rsync/etc transfer from the command-line? ie, manual QoS on a single command?

10

1

Specifically, I am looking to rate-limit an scp or sftp session (or other arbitrary network call) in the call itself.

For example, let's say I want to copy 100MB to one server, and 1GB to another. I'd like to be able to run both of these at the same time, but maintain a QoS for "normal" computer usage - somewhat similar to how you can rate-limit bittorrent.

Is there a way to do this without touching the networking hardware?

I'm envisioning something akin to:

magic-qos-tool 'scp file user@host:/path/to/file'

Or..

scp -rate 40kbps file user@host:/path/to/file

warren

Posted 2010-04-02T20:45:40.383

Reputation: 8 599

Answers

12

Yes, there's an application that works exactly like your 'magic-qos-tool', called "trickle".

EXAMPLES
     trickle -u 10 -d 20 ncftp

     Launch ncftp(1) limiting its upload capacity to 10 KB/s, and download ca-
     pacity at 20 KB/s.

davr

Posted 2010-04-02T20:45:40.383

Reputation: 4 809

1thanks, @davr - one wrapper tool vs learning all the options to each is a great improvement :) – warren – 2010-04-08T14:51:25.513

16

scp has -l, and rsync has --bwlimit.

Ignacio Vazquez-Abrams

Posted 2010-04-02T20:45:40.383

Reputation: 100 516

that was not an option in the man page I checked earlier... looks like it depends on the platform, perhaps? – warren – 2010-04-02T20:52:05.627

Quite possibly. I have OpenSSH 5.3p1 here. – Ignacio Vazquez-Abrams – 2010-04-02T20:55:41.190

The -l flag in scp doesn't work on Solaris 11. Is there any other option or alternative? – Alchemist – 2016-10-11T14:57:08.357

XenServer 6 has scp with -l option – Brian Boatright – 2012-05-28T21:06:23.637

7

Rsync makes this easy on you, it has an option to do this: --bwlimit=KBPS

kbyrd

Posted 2010-04-02T20:45:40.383

Reputation: 2 067

2

sftp has a throttle flag, as of Debian 7 and Ubuntu 12.04 in those distributions:

-l limit

    Limits the used bandwidth, specified in Kbit/s.

(Of course that's a lower case L.)

Source: stfp(1)

Thom Luxford

Posted 2010-04-02T20:45:40.383

Reputation: 21