Lance Pollard
Lance Pollard

Reputation: 79168

How to kill bash script with CTRL+C

I have a bash script which runs a function 10 times, and this function runs 20 imagemagick commands. Every time I press ctrl+C it moves onto the next imagemagick command so it takes 200 ctrl+c's to close the file.

How do I stop it with ctrl+c properly?

Upvotes: 2

Views: 958

Answers (2)

nullPointer
nullPointer

Reputation: 4574

Try Ctrl+Z (suspend) and then check output of jobs command. Your script / job should be listed as "Stopped". Then you could simply run kill %i where i is the number inside the [] in jobs output.

Alternatively you could issue a pkill -9 -f <your_script_name> from another session

Upvotes: 2

eliana_zulato
eliana_zulato

Reputation: 11

check this answer "How to kill a script running in terminal, without closing terminal (Ctrl + C doesn't work)?": https://askubuntu.com/questions/520107/how-to-kill-a-script-running-in-terminal-without-closing-terminal-ctrl-c-doe

Upvotes: 0

Related Questions