0

I started my shell script using something like the following:

sh python3_start.sh

How do I stop this completely? If the process is already running and I do a cntrl + c it seems like it stops it but I don't know if it's not entirely killed in the background.

0

2 Answers 2

1

Run the following command to list all processes and extract the ones that contain "python3_start.sh":

ps ax | grep -i python3_start.sh

then you can use the "pid" ("pid" is the number in the beginning of each line) and run:

kill "pid"

if the first command only produces something like this:

28952 s000  S+     0:00.01 grep -i python3_start.sh

then you don't have your script running in the background.

Change "python3_start.sh" in the first command to any process you want to see is running and follow the same steps to kill it.

Sign up to request clarification or add additional context in comments.

Comments

1

Run the script, while it is running type the following into a different terminal session

top

If you see the script running in there then it is, if not the script has stopped. You might want to put some temporary sleep timers in your script so you can be sure. To do this add this somewhere within your python code. Make sure you are also importing time as well.

time.sleep(30)

If you need to kill the script from terminal you can do this as well. To do this run the following command in a different terminal session.

kill -9 "pid next to script in top" 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.