gpt4 book ai didi

bash - 使用 aria2c 并行下载多个文件

转载 作者:行者123 更新时间:2023-12-04 01:47:09 29 4
gpt4 key购买 nike

我想使用以下代码与 aria2c 并行下载多个 torrent 文件:

me@host:~/Downloads$ find . -iregex ".*.torrent"  | while read line; do nohup aria2c "$line" &; done
bash: syntax error near unexpected token `;'

用子shell解决问题

me@host:~/Downloads$ find . -iregex ".*.torrent"  | while read line; do (nohup aria2c "$line" &); done
nohup: nohup: appending output to 'nohup.out'
appending output to 'nohup.out'
nohup: appending output to 'nohup.out'
nohup: appending output to 'nohup.out'
nohup: appending output to 'nohup.out'
nohup: appending output to 'nohup.out'
nohup: appending output to 'nohup.out'
nohup: appending output to 'nohup.out'
nohup: appending output to 'nohup.out'
nohup: appending output to 'nohup.out'
nohup: appending output to 'nohup.out'

但是所有进程都在stop进程中

me@host:~/Downloads$ ps -aux | grep 'aria'| sed "s/$USER/me/g"
me 5807 0.1 0.4 86208 18392 pts/0 S 22:58 0:00 aria2c ./ebd9863a73a5ef22344550a650d169a1.torrent
me 5809 0.0 0.4 85804 17884 pts/0 S 22:58 0:00 aria2c ./53ef22110569d46b445a1e908a7ae88f.torrent
me 5811 0.1 0.4 87336 19408 pts/0 S 22:58 0:00 aria2c ./a51accbbf14c8a05cb82caa7d8bec0c6.torrent
me 5813 0.0 0.4 84260 16528 pts/0 S 22:58 0:00 aria2c ./0eae6a261a340b8af159c0155aa8fab6.torrent
me 5815 0.0 0.3 82972 14400 pts/0 S 22:58 0:00 aria2c ./bf93f4618ba007ff95113156c802812b.torrent
me 5817 0.0 0.4 84256 16376 pts/0 S 22:58 0:00 aria2c ./f5938dd24367ffaf766ef99928660786.torrent
me 5819 0.0 0.4 86132 18440 pts/0 S 22:58 0:00 aria2c ./61ee21f83a33b91674926daf70c34947.torrent
me 5821 0.0 0.4 84100 16296 pts/0 S 22:58 0:00 aria2c ./710fc8dc201568d807aa7709b8fa072a.torrent
me 5823 0.0 0.3 82972 14364 pts/0 S 22:58 0:00 aria2c ./2b9cc942c04a8063bd8d4d8fd98814d9.torrent
me 5825 0.0 0.4 85832 18340 pts/0 S 22:58 0:00 aria2c ./8ffc0566591e1258c151d4d28843c55b.torrent
me 5827 0.0 0.3 82972 15208 pts/0 S 22:58 0:00 aria2c ./d9e39bfe0a907ffb580a975d8c8719d2.torrent
me 5829 0.0 0.3 83692 15616 pts/0 S 22:58 0:00 aria2c ./EDBDB765D87586FDA75C4287A1E9EA1E.torrent
me 5933 0.0 0.0 11928 956 pts/0 S+ 23:04 0:00 grep --color=auto aria

git 怎么可能完成?

最佳答案

我不知道 aria2c,但并行处理事情的一种简单方法通常是使用 GNU Parallel

find . -iregex ".*.torrent" -print0 | parallel -0 aria2c

这将为您的 CPU 的每个内核并行运行一个 aria2c,直到所有文件都下载完毕。如果出于某种原因,您特别想一次运行 32 个,请使用:

find ... | parallel -0 -j32 ...

如果你想要一个进度表,使用:

find ... | parallel -0 --eta ...

更多示例和想法 here .

关于bash - 使用 aria2c 并行下载多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54853223/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com