# Python GNU parallel single command on multiple cores

**URL:** <https://community.unix.com/t/python-gnu-parallel-single-command-on-multiple-cores/362213>\
**Category:** Shell Programming and Scripting\
**Created:** [August 29, 2016, 10:46am UTC](https://community.unix.com/t/python-gnu-parallel-single-command-on-multiple-cores/362213 "2016-08-29T10:46:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobs.smith](https://community.unix.com/letter_avatar/jacobs.smith/32/5_5575768a8748004e209b776fc1b2916d.png) [@jacobs.smith](https://community.unix.com/u/jacobs.smith)\
**Post date:** [August 29, 2016, 10:46am UTC](https://community.unix.com/t/python-gnu-parallel-single-command-on-multiple-cores/362213/1 "2016-08-29T10:46:09Z")

</div>

Hello,

I have a 4 core machine.

Here is my initial script

```nohighlight
cd /work/
python script.py input.txt output.txt 1 2 3

```

This script runs for 1.5hrs.

So I read across the web and figured out that you can use GNU parallel to submit multiple jobs using parallel. But I am not sure if I can run single command on multiple processors. Still, I went ahead and used the following command

```nohighlight
cd /work/
parallel python script.py input.txt output.txt 1 2 3

```

Here is the error

```nohighlight
parallel: Warning: Input is read from the terminal. Only experts do this on purpose. Press CTRL-D to exit.

```

---

<div class="post-metadata">

**Author:** ![RavinderSingh13](https://community.unix.com/letter_avatar/ravindersingh13/32/5_5575768a8748004e209b776fc1b2916d.png) [@RavinderSingh13](https://community.unix.com/u/RavinderSingh13)\
**Post date:** [August 29, 2016, 10:57am UTC](https://community.unix.com/t/python-gnu-parallel-single-command-on-multiple-cores/362213/2 "2016-08-29T10:57:22Z")

</div>

> [@jacobs.smith](#):
>
> ```plaintext
> cd /work/
> parallel python script.py input.txt output.txt 1 2 3
> 
> ```
> 
> Here is the error
> 
> ```plaintext
> parallel: Warning: Input is read from the terminal. Only experts do this on purpose. Press CTRL-D to exit.
> 
> ```

Hello Jacobs.smith,

Not sure about your complete code/requirement(as you haven't shown us) but seems like it may be code is executing a process into a sub-shell then there it is expecting a variable to be passed rather than it gets passed while running the script.

Thanks,  
R. Singh

---

<div class="post-metadata">

**Author:** ![jacobs.smith](https://community.unix.com/letter_avatar/jacobs.smith/32/5_5575768a8748004e209b776fc1b2916d.png) [@jacobs.smith](https://community.unix.com/u/jacobs.smith)\
**Post date:** [August 29, 2016, 11:03am UTC](https://community.unix.com/t/python-gnu-parallel-single-command-on-multiple-cores/362213/3 "2016-08-29T11:03:15Z")

</div>

But the script is designed to take inputs from the terminal itself.

Do you know of a way where I can run a python command on multiple processors instead of one?

Thank you for your time R.Singh.

---

<div class="post-metadata">

**Author:** ![balajesuri](https://community.unix.com/user_avatar/community.unix.com/balajesuri/32/1423_2.png) [@balajesuri](https://community.unix.com/u/balajesuri)\
**Post date:** [August 29, 2016, 12:32pm UTC](https://community.unix.com/t/python-gnu-parallel-single-command-on-multiple-cores/362213/4 "2016-08-29T12:32:24Z")

</div>

Can you modify the python script and use the [multiprocessing](https://docs.python.org/2/library/multiprocessing.html)module.

---

<div class="post-metadata">

**Author:** ![jacobs.smith](https://community.unix.com/letter_avatar/jacobs.smith/32/5_5575768a8748004e209b776fc1b2916d.png) [@jacobs.smith](https://community.unix.com/u/jacobs.smith)\
**Post date:** [August 29, 2016, 12:58pm UTC](https://community.unix.com/t/python-gnu-parallel-single-command-on-multiple-cores/362213/5 "2016-08-29T12:58:14Z")

</div>

All I can access it is for execution only.

I cannot edit it.
