简体   繁体   English

从MacOS终端筛选输出并行运行多个python脚本

[英]Running multiple python scripts in parallel from MacOS terminal screening output

I am trying to run multiple python scripts in parallel from macos terminal via 我正在尝试通过macOS终端并行运行多个python脚本

python a.py &
python b.py &
python c.py &

Does this run the scripts concurrently in parallel, asynchronously? 这样是否可以并行,异步并行运行脚本? Or are they still run sequentially? 还是它们仍按顺序运行? I intend for the former, to save time. 我打算使用前者,以节省时间。 Moreover, the output from these scripts seems to overlap in the terminal window. 此外,这些脚本的输出似乎在终端窗口中重叠。 Is there a way to screen the output from each program to a different terminal window, and maybe even write it to a separate text file. 有没有一种方法可以将每个程序的输出屏蔽到另一个终端窗口,甚至可以将其写入单独的文本文件。

This should work. 这应该工作。 These are three separate processes that run separate from each other. 这是三个相互独立运行的独立进程。 Concurrency and parallelism might also depend on the number of cores in the machine and the processor os scheduler. 并发性和并行性还可能取决于计算机和处理器os调度程序中的内核数量。

python a.py > a.out 2>&1 &
python b.py > b.out 2>&1 &
python c.py > c.out 2>&1 & 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM