I'd like to kill a process/script with a simple command using. At the moment I do the following
ps -ef | grep myscriptname
kill 123456
But is there a way to maybe combine the 2 command together so I don't need to look and manually write the pid, something like this kill grep myscriptname
?
You want pkill
:
pkill myscriptname
On some systems there is a similar tool called killall
, but be careful because on Solaris it really does kill everything!
Note that there is also pgrep
which you can use to replace your ps | grep
pipeline:
pgrep myscriptname
It prints the PID for you, and nothing else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With