Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
39
rated 0 times [  39] [ 0]  / answers: 1 / hits: 99682  / 2 Years ago, sun, july 31, 2022, 8:28:20

Is there a way (perhaps a script) how to automate this process:



petr@sova:~$ ps -ef | grep middleman
petr 18445 2312 1 12:06 pts/2 00:00:01 /home/petr/.rvm/gems/ruby-1.9.3-p362/bin/middleman
petr 18581 13621 0 12:08 pts/0 00:00:00 grep --color=auto middleman
petr@sova:~$ kill -9 18445


Unfortunately, pkill is too weak as I have to go with -9 option on kill.


More From » bash

 Answers
4

You can use your shell to do this task for you:



kill -9 $(pidof middleman)


The shell executes the command pidof middleman first. The output of pidof(8) is the process id. So the shell substitutes the pidof-command with the process id and executes kill -9 18845 (or whatever the correct process id is).


[#33245] Sunday, July 31, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gigglcept

Total Points: 113
Total Questions: 105
Total Answers: 125

Location: Christmas Island
Member since Wed, Jan 13, 2021
3 Years ago
;