limit-rate: shell skript for the speed surveillance of a (file/pipe) transfer

After having uploaded lines/getline recently, now I upload another nice thing: limit-rate!

It's task is to control (i. e. to slow down) the speed of a transfer (can be a file copy operation or a pipe transfer).

The main technique used for that is:

Unfortunately the script is not finished at all. As user you may need to adapt it to your requirements and the actual system. (E. g. allow even shorter time periods than set up by default.)

How it works is visualized below by a nices sample run. Have fun playing with the script!

Remark: only use the program in a private scope.


Verwendung (Linux, BSD, Windows (cygwin), OS X (?)):

  1. Herunterladen: Version 1.03
  2. In ein neues/leeres Verzeichnis (!) entpacken (Unpack into an empty dir!)
  3. Uund ... ausführen!
    # (echo 1000 >RATE.tmp; sleep 10; echo 800000 >RATE.tmp) & sleep 0.2; ./limit-rate.sh src=/.../Filme/.../big-movie-file.avi tgt=/dev/null ratefile=RATE.tmp
    [4] 25579
    ./limit-rate.sh: src = '/.../Filme/.../big-movie-file.avi'
    ./limit-rate.sh: tgt = '/dev/null'
    ./limit-rate.sh: rate = 1024 B/s
    copy-file: rate:    15360/    [15360]/     1024      -> time 100, dd_bs   1024
    copy-file: rate:     8192/     [8192]/     1000      -> time 200, dd_bs   1024
    copy-file: rate:     5120/     [5120]/     1000      -> time 400, dd_bs   1024
    copy-file: rate:     2048/     [2048]/     1000      -> time 400, dd_bs    512
    copy-file: rate:     1536/     [1536]/     1000      -> time 400, dd_bs    256
    copy-file: rate:      512/      [512]/     1000      -> time 200, dd_bs    256
    copy-file: rate:     1024/     [1024]/     1000      -> time 220, dd_bs    231
    copy-file: rate:      924/      [924]/     1000      -> time 198, dd_bs    254
    copy-file: rate:     1270/     [1270]/     1000      -> time 217, dd_bs    229
    copy-file: rate:      916/      [916]/     1000      -> time 196, dd_bs    251
    copy-file: rate:     1255/     [1255]/   800000      -> time  98, dd_bs    251
    copy-file: rate:     1757/     [1757]/   800000      -> time  49, dd_bs    251
    copy-file: rate:     3514/     [3514]/   800000      -> time  24, dd_bs    251
    copy-file: rate:     5271/     [5271]/   800000      -> time  12, dd_bs    251
    copy-file: rate:     7028/     [7028]/   800000      -> time  12, dd_bs    502
    copy-file: rate:    14558/    [14558]/   800000      -> time  12, dd_bs   1004
    copy-file: rate:    28112/    [28112]/   800000      -> time  12, dd_bs   2008
    copy-file: rate:    58232/    [58232]/   800000      -> time  12, dd_bs   4016
    copy-file: rate:   116464/   [116464]/   800000      -> time  12, dd_bs   8032
    copy-file: rate:   224896/   [224896]/   800000      -> time  12, dd_bs  16064
    copy-file: rate:   449792/   [449792]/   800000      -> time  12, dd_bs  32128
    copy-file: rate:   899584/   [899584]/   800000      -> time  13, dd_bs  28916
    copy-file: rate:   809648/   [809648]/   800000      -> time  14, dd_bs  26025
    copy-file: rate:   702675/   [702675]/   800000      -> time  13, dd_bs  28627
    copy-file: rate:   744302/   [744302]/   800000      -> time  12, dd_bs  31489
    copy-file: rate:   881692/   [881692]/   800000      -> time  13, dd_bs  28341
    copy-file: rate:   793548/   [793548]/   800000      -> time  12, dd_bs  31175
    copy-file: rate:   872900/   [872900]/   800000      -> time  13, dd_bs  28058
    copy-file: rate:   757566/   [757566]/   800000      -> time  12, dd_bs  30863
    copy-file: rate:   833301/   [833301]/   800000      -> time  13, dd_bs  27777
    copy-file: rate:   722202/   [722202]/   800000      -> time  12, dd_bs  30554
    copy-file: rate:   886066/   [886066]/   800000      -> time  13, dd_bs  27499
    ^C[4]+  Fertig                  ( echo 1000 > RATE.tmp; sleep 10; echo 800000 > RATE.tmp )
    
     130  ((echo 1000 >RATE.tmp; sleep 10; echo 800000 >RATE.tmp) & sleep 0.2; ....)
    #
    

Document of July 2015, last modification on 3 January 2024. Page source

Hintergrundbild: Schräge Vorderansicht der Lok 1142.562-9