1

I must terminate a Python script and 2 bash scripts using crontab.

I needed a command to terminate all bash scripts ('killall Python' already works for terminating the python script) but when i use 'killall bash' it doesn't works...

Does anyone knows a solution to my problem? Maybe another command, or an especific way to use killall!

Thanks in advance!

Manoel Ribeiro
  • 374
  • 1
  • 12

2 Answers2

1

Try the following command :

killall -s SIGHUP bash

but you shouldn't do this, you can potentially kill all bash of all users. Instead, I recommend you to use

pkill -f script_name.bash

and

pkill -1 -f script_name.bash

if needed.

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
-1

Bash traps many signals like SIGTERM(15) and SIGQUIT(3). You could send SIGHUP(1) or SIGKILL(9):

killall -s SIGHUP bash   ## or killall -s 1 bash
killall -s SIGKILL bash  ## or killall -s 9 bash
konsolebox
  • 72,135
  • 12
  • 99
  • 105
  • 1
    Nobody should use `kill -9` without a good reason. See http://stackoverflow.com/a/690631/347411 and the 1st command is already given. – Gilles Quénot Aug 13 '13 at 18:18
  • 2
    [Don't use `kill -9`!](http://partmaps.org/era/unix/award.html#kill) – tripleee Aug 13 '13 at 18:21
  • Killing a stopped bash doesn't work with SIGHUP. And probably some other conditions too. You could avoid telling such kinds of information but it's too easy to be known sooner. – konsolebox Aug 13 '13 at 18:27