linux批处理并行作业 [英] linux batch jobs in parallel

查看:98
本文介绍了linux批处理并行作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有七个特定软件的许可证.因此,我想同时开始7个工作.我可以使用&"来做到这一点.现在,"wait"命令一直等到所有这7个进程的结束都完成后才产生下一个7.现在,我想编写一个shell脚本,在启动前七个任务之后,以及何时完成一项工作我想开始另一个.这是因为这7个工作中的一些可能会花费很长时间,而另一些则很快就可以解决.我不想浪费时间等待所有人完成.在Linux中有没有办法做到这一点?你能帮我吗?

I have seven licenses of a particular software. Therefore, I want to start 7 jobs simultaneously. I can do that using '&'. Now, 'wait' command waits till the end of all of those 7 processes to be finished to spawn the next 7. Now, I would like to write the shell script where after I start the first seven, as and when a job gets completed I would like to start another. This is because some of those 7 jobs might take very long while some others get over really quickly. I don't want to waste time waiting for all of them to finish. Is there a way to do this in linux? Could you please help me?

谢谢.

推荐答案

您可以检查当前正在运行的数量,如果少于7个则可以启动更多的产品:

You could check how many are currently running and start more if you have less than 7:

while true; do
    if [ "`ps ax -o comm | grep process-name | wc -l`" -lt 7 ]; then
        process-name &
    fi
    sleep 1
done

这篇关于linux批处理并行作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆