Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer
    
assuming you dont know how to kill a process, its basically like kill "process name" –  Jasen Jan 4 '11 at 11:01
    
I do know how to kill a process, but I want to make it as easy as Ctrl-C –  Gabi Purcaru Jan 4 '11 at 11:16
    
which version of linux are you running? I dont want to sound irritated, but i just gave you the answer on a version of linux, and i could probably custom tailor the solution if i knew which version you were using. Or, you missed the answer. one of the two. –  Jasen Jan 4 '11 at 11:19
    
@Jason sorry about that, I modified the question. –  Gabi Purcaru Jan 4 '11 at 11:23
    
I added more to my answer im thinking it should do what you want. if i need to clarify a step, i wont be mad ha ha. –  Jasen Jan 4 '11 at 11:38

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

share|improve this answer

pstree

and then kill the root process using kill or pskill these command might not be available in your distro

share|improve this answer
    
just read the extra info, well my other suggestion is to make a script and call the daemon from this script, killing the script process should delete it. –  afifio Jan 4 '11 at 11:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.