3 ms·
I also do that, often with loops. for ((i=0;i<4;++i)); do (./ad-hoc-operation >out-$i.log 2>&1 ) & done Can be anything from image processing, video trans
by barrkel 8y ago
I also do that, often with loops.
for ((i=0;i<4;++i)); do (./ad-hoc-operation >out-$i.log 2>&1 ) & done
Can be anything from image processing, video transcoding, file decompression, file system analysis - anything I think may complete faster with some concurrency.
- CJefferson 8y agoThat's a nicer notation than me! I thought you needed a ; before the 'done', and & ; won't parse.
- brendyn 8y agoSomething like this should do the same thing, I think?: seq 0 3 | parallel "./ad-hoc-operation > out-{}.log" https://www.gnu.org/software/parallel/ https://www.gnu.org/software/parallel/
- CJefferson 8y agoWith longer expressions, I find the escaping gets tricky. Also gnu parallel has stupid licence problems and the author has told me I can't use it without paying him.
- barrkel 8y agoMight do. OTOH I often have a shell pipeline as the body of the loop, rely on glob expansion, etc. For ad-hoc parallelism of a simple command over lots of data, I tend to use xargs -n -P - since I use xargs for other things, I stick with it. Also, bash and xargs are available everywhere, on production servers as well as dev laptops. Anything that requires installing something has a big hurdle to overcome - this counts for fish too.