我可以编程选择一个免费的CPU,我有多个,来运行我的shell脚本吗?

前端之家收集整理的这篇文章主要介绍了我可以编程选择一个免费的CPU,我有多个,来运行我的shell脚本吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个 shell脚本.在那个脚本中,我开始了6个新进程.我的系统有4个cpu.
如果我运行shell脚本,则生成的新进程默认由操作系统自动分配给其中一个cpu.现在,我想减少运行脚本的总时间.有没有办法可以检查处理器的免费利用率,然后选择一个来运行我的流程?

我不想在使用率> 75%的cpu上运行进程.我会等待并使用<75%的cpu运行. 我需要以这样一种方式编写脚本,它应该检查4个cpu的利用率,然后在所选的cpu上运行该进程. 有人可以帮我举个例子吗?

我推荐 GNU Parallel

GNU parallel is a shell tool for executing jobs in parallel using one or more computers. A job can be a single command or a small script that has to be run for each of the lines in the input. The typical input is a list of files,a list of hosts,a list of users,a list of URLs,or a list of tables. A job can also be a command that reads from a pipe. GNU parallel can then split the input and pipe it into commands in parallel.

另外,使用nice.

猜你在找的Bash相关文章