如何从父级并行运行两个子命令? [英] How to run in parallel two child command from a parent one?

查看:54
本文介绍了如何从父级并行运行两个子命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一个并行运行两个 perl 脚本.我怎样才能做到这一点?

I need to run two perl scripts from one in parallel. How can I accomplish this?

目前,我有一个文件

system("perl command1.pl command2.pl"); 

命令按顺序执行,直到 command1.pl 完成 command2.pl 才会运行.

Commands are executed in sequence and until command1.pl is done command2.pl won't run.

我想同时运行这两个命令.

I would like to run the two commands simultaneously.

请帮助!

推荐答案

`perl command1.pl &`;

`perl command1.pl &`;

`perl command2.pl &`;

`perl command2.pl &`;

..或使用 perl fork() 函数

..or use the perl fork() function

perldoc -f fork

perldoc -f fork

...或使用 perl 线程

..or use perl threading

perldoc 线程

或者只是使用 shell 脚本:

Or just use a shell script:

#!/bin/sh
./command1.pl &
./command2.pl &

这篇关于如何从父级并行运行两个子命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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