小编noo*_*lag的帖子

Bash:使用变量来动态调整 rsync 的时间安排并在运行时放慢速度?

在命令已经启动后bash 脚本期间运行动态流量整形有哪些解决方案?这甚至可能吗?

我的用例是,我rsync在大量磁盘上运行到远程备份位置,这在 Internet 上需要很多小时,所以我想将流量整形应用于rsync调用的线路,但仅限于指定时间。

因此,例如,当前的计划是在上午 5 点到上午 10 点和下午 3 点到晚上 9 点将上传减少到每秒 1000 KB (1.0MB/s)。

我已经看过了--bwlimit=1000rsync但这会rsync在它运行的整个时间里形成而不仅仅是所需的塑造时间框架

rsync启动后可以减速吗?因为如果以某种方式可能,那将是我的解决方案。

我见过有人建议,wondershaper但我想知道这是否可以以编程方式“打开和关闭”?如果是,如何做到这一点?

这是一个模型,我使用 Stackoverflow 的慷慨贡献对它进行了黑客攻击,它提供了指定和检查时间表的功能(基于小时,这对我目前的需求来说很好)......

#!/bin/bash

declare -A shapingTimes
declare -A keycount

useTrafficShaping=1

# schedule
shapingTimes=([0-from]=5 [0-to]=10)  # 5am to 10am
shapingTimes+=([1-from]=15 [1-to]=21)  # 3pm to 9pm

# because keys and array content differs in order from the way they are defined, …
Run Code Online (Sandbox Code Playgroud)

networking backup bash rsync traffic-shaping

5
推荐指数
1
解决办法
352
查看次数

标签 统计

backup ×1

bash ×1

networking ×1

rsync ×1

traffic-shaping ×1