[Solved] Stopping a runaway bash script

Asked by Julianloui

2014-09-19

I would like to know how to stop a running bash script quickly. I find it annoying not being able to cancel a running show-and tell script I've written, which is based on espeak and shotwell. I've tried ctl+c, ctl+x and some terminal commands to no avail.

Any help will be much appreciated.

julianloui

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gparted Edit question
Assignee:
No assignee Edit question
Solved by:
Thomas Krüger
Solved:
Last query:
Last reply:
Revision history for this message
Best Thomas Krüger (thkrueger) said :
#1

If you can not stop a script with ^C you wtill have the option to "kill" it.
Open the Terminal, get a list of the running processes for example with

ps ax

find out the PID of the script.
Then run

kill PID

with the PID you founf out of cause. If the script is really stuck you can add the parmeter -9:

kill -9 PID

If the script is run by an other user you have to prefix the command with "sudo ":

sudo kill -9 PID

There is also "killall" which kills all processes what match an expression. See "man killall" for details.

Revision history for this message
Julianloui (julianloui) said :
#2

Thomas,

Thank you very much for a powerful solution. I've just tried out 'ps ax' in Linux mint 17 to find the PID of a running script and it worked. I wish Linux Mint would allow the user to use Alt+Ctl+T to open a new terminal.

Julianloui

Revision history for this message
Julianloui (julianloui) said :
#3

Thanks Thomas Krüger, that solved my question.