0

I have a bash script which executes multiple python scripts.
For example:

python pyscript.py &> log1
python pyscript2.py &> log2

while executing this script, I found a few error in python script.
So I tried to kill process simply by ctrl-c, which did not work.

When I looked up at process by ps -ef pyscript*, this single bash file made multiple process at once, which I did not expected it to be.

eventually I killed all processes by hand, but it was not a clean way to do.
Is there a reason that this bash script makes multiple process?

thanks in advance

이준혁
  • 267
  • 4
  • 14
  • 1
    You ran it with `sh` instead of bash. `&>` is only special in bash, so in `sh` it acts like `& >`, first creating a background process, and then (separately) creating an empty file (without redirecting the process's output to the file). – Charles Duffy Feb 12 '22 at 17:15
  • what does your `pyscript.py` do? – Giovanni Rescia Feb 12 '22 at 17:15
  • 2
    ...really, it's best to avoid `&>` altogether and use `python pyscript.py >log1 2>&1` in the first place. That fixes the unintended backgrounding, and _also_ makes your code compatible with `sh`. – Charles Duffy Feb 12 '22 at 17:16
  • @GiovanniRescia it runs deep learning process, which takes a lot of time – 이준혁 Feb 12 '22 at 17:18
  • try ctrl-z. in some situation ctrl-c doesn't make any interrupt for current process – kareem alkoul Feb 12 '22 at 18:57

0 Answers0