# Falls Sie eine Website erwarten, aber diesen # Abschnitt lesen können, löschen Sie bitte das # _index.htmx_limit-rate # vom Ende der Adresszeile. Danke! Lang: de Title: limit-rate: Shell-Skript zur Geschwindigkeitsbegrenzung eines (Datei-/Pipe-)Transfervorgangs Short Title: limit-rate: (Datei-/Pipe-)Transfer verlangsamen Publication date: 2015-07 Meta: en Title: limit-rate: Shell script to limit the speed of a (file/pipe) transfer. Short Title: limit-rate: slow down (file/pipe) transfer +INFO +usage >>INFO de 1.0
Nachdem ich vor kurzem lines/getline hochgeladen habe, kommt jetzt ein viel cooleres Shell-Skript an die Reihe: limit-rate.
Seine Aufgabe ist es, die Geschwindigkeit eines Transfers, der ein Dateikopiervorgang sein kann, aber auch über Pipes laufen kann, zu steuern (d. h. zu verlangsamen).
Im Kern wird die folgende Technik angewandt:
Das Skript ist natürlich ganz und gar nicht ausgereift. Als Anwender muss man es ggf. an die Anforderungen und an das jeweilige System anpassen (z. B. noch kürzere Zeitabstände erlauben.)
Die Funktionsweise ist mit dem Beispielaufruf (unten) schön visualisiert. Viel Spaß beim Ausprobieren!
Hinweis: die Nutzung ist nur privat, d. h. im kleinen Rahmen, gestattet.
<< INFO de >>INFO en 0.8After 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.
<< INFO en >> usage de 1.0Verwendung (Linux, BSD, Windows (cygwin), OS X (?)):
# (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; ....) #