How to close all background processes in unix?

I have something like:

cd project && python manage.py runserver &
cd utilities && ./coffee_auto_compiler.py

And I want both of them to close on Ctrl-C (or some other command). How can I accomplish that?

EDIT: I tried using jobs -x kill and kill ``jobs -p , but it doesn't seem to kill what I need. Here is what I mean:

moon      8119  0.0  0.0   7556  3008 pts/0    S    13:17   0:00 /bin/bash
moon      8120  6.8  0.4  24568 18928 pts/0    S    13:17   0:00 python manage.py runserver

jobs -p give me just process 8119, but I also need to close 8120, since it's the thing that the first command opened.

If it helps, the commands are actually in a Makefile, and I want it to run two daemons at the same time (and somehow close them at the same time). And yes, I'm using ubuntu, with bash


easiest way? since i dont know which distro you are using, ill assume its ubuntu. system>preferences>keyboard shortcuts. click add, name it, paste in your commands like this: "command1","command2" click add. click on the new shortcut, set shortcut key.

If that doesnt work for some reason, create a launcher with the commands, make sure it does what you want, and then use the above instructions to bind the launcher to the shortcut.


To kill all background the jobs running under the Korn shell (ksh) or Bourne-again shell (bash), enter:

kill `jobs -p`

In bash, you may also use the following variant:

jobs -x kill

source