Sample Header Ad - 728x90

How to kill python process ran by shell script when shell script dies?

1 vote
2 answers
2211 views
I have a shell script that runs python. **start.sh**
# Setup environment
cd ~/foobar/ && \
    python3 -m venv env && \
    source env/bin/activate && \
    pip install -q -r requirements.txt && \
    find . -maxdepth 1 -type f -name "*.py" | xargs pylint

# Run scripts
python ~/foobar/main.py
If I ctrl+c in the terminal, it will shutdown the python properly. However if I pkill -9 start.sh, it will prompt Killed but the python is still running. Is there a way to kill the python script when the calling script dies?
Asked by ACD (111 rep)
Jun 4, 2020, 10:13 AM
Last activity: Jul 4, 2025, 01:01 AM