我有一个
shell脚本.在那个脚本中,我开始了6个新进程.我的系统有4个cpu.
如果我运行shell脚本,则生成的新进程默认由操作系统自动分配给其中一个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
.