I am currently using the following command to get a process:
ps -xa | grep node
Which results in the following:
13611 ? Sl 0:03 /opt/brackets/Brackets-node /opt/brackets/node-core
20713 pts/1 Sl 0:00 node --harmony app.js
20838 pts/1 S+ 0:00 grep node
I use the command kill -9 20713
to kill the node --harmony app.js
process.
How can I kill the node --harmony app.js
every single time with one command? I am tired of typing in the process number every time.
Use
pkill
:This would match the other command as well, so fine tune it:
This matches the full command line (
-f
) exactly, so it should only hit the desired command.You can use
killall
. The simplest syntax is:In you case:
The upside of
killall
is that it will match the exact name so there is no chance of killing other processes unwantedly.Although you can use
-r
option to express the process as a regular expression pattern likepkill
.Check
man killall
for more info.Use an alias and your own "command word" for it.
E.G.go to your home Dir and create the file .bash_aliases
Put the following text into the file
and then search in your home folder for your .bashrc looking for this part and make sure it's not commented out.
Now type into your terminal
and try your brand new "command" a.k.a. alias
nerdalert
Enjoy ^^