I want a way to kill a random process with a name (eg a random perl process).
What would be the best way of doing this?
I was thinkign of using something like this:
ps aux | grep PROCESS-NAME
to a file, then find a random line number, get the second column (process ID?) and kill that.
For my use it doesn't actually need to be a random one, as long as it kills one of the processes. Making it random just makes it better.
kill process with name "my_proc_name" :
Maybe off topic, but I use this on Cygwin. Inspired by Lev Victorovich Priyma’s answer
or
just kill and awk.
the for loop in the END block will give you you a random pid to kill