I wanted to add an alias to my .bashrc so that I could kill all stopped jobs with a command like kill_stopped. I am aware that kill `jobs -p` can be used to accomplish this but I'd rather have an easier-to-remember alias for convenience sake. So I added this line to my .bashrc:

alias kill_stopped="kill `jobs -p`"

However, when I run it I get a message about the usage of the kill command. To make sure it was being run properly I ran echo "kill `jobs -p`" in the shell and got back "kill <some number>" whenever I had a stopped process. Can anyone help me fix this?

  • Can you post what you added in your bashrc file?
    – ryekayo
    Oct 20, 2014 at 16:52
  • What makes you think that kill `jobs -p` will kill stopped jobs? That will only kill jobs launched from the particular shell you are running and it will kill all of them, irrespective of if they're active or not. Is that really what you want? What exactly do you mean by "stopped"?
    – terdon
    Oct 20, 2014 at 18:55
  • If you really want stopped jobs, you want jobs -p -s. The -s flag is a bash extension and won't necessarily work in other shells.
    – Jander
    Oct 20, 2014 at 19:35

2 Answers 2


You were close, but you should use single quotes, not double quotes:

kill_stopped='kill `jobs -p` '

Backticks are expanded inside double quotes, so it was running jobs -p at the time you defined the alias, not when you used it.


Try this:

alias kill_stopped="kill \$(jobs -p)"

and to kill runnings jobs:


If there are no running jobs you get a message about the usage of the kill.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .