gpt4 book ai didi

background - 将 xargs 生成的命令发送到后台

转载 作者:行者123 更新时间:2023-12-02 23:44:30 24 4
gpt4 key购买 nike

我想知道如何将 xargs 生成的命令发送到后台。例如,考虑

find . -type f  -mtime +7 | tee compressedP.list | xargs compress

我试过了

find . -type f  -mtime +7 | tee compressedP.list | xargs -i{} compress {} &

..出乎意料的是,它似乎将 xargs 发送到后台?

如何使压缩命令的每个实例转到后台?

最佳答案

使用 --max-procs/-P 选项在后台运行 xargs 目标。来自 GNU xargs 版本 4.2.27 的手册页:

--max-procs=max-procs, -P max-procs

Run up to max-procs processes at a time; the default is 1. If max-procs is 0, xargs will run as many processes as possible at a time. Use the -n option with -P; otherwise chances are that only one exec will be done.

(您可能需要将其与 -n 1 结合使用,以确保您要压缩的每个文件都有一个新进程)

关于background - 将 xargs 生成的命令发送到后台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1952265/

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