In the past, I used psKill . It is really powerful and possibly dangerous. You kill multiprocesses even on a remote computer. I think you know that we must be very careful when we want to kill a cruel process.
- Download the tool, unzip and copy along the known path.
- The first time you start, you request liscence. You run it from cmd once, and you agree.
Then you use something like this
process_name <- 'your_process_name' system(paste(path_to_pskil,'pskill ',process_name,sep=''),intern=T)
For example, to kill all instances of chrome, you do this
system('c:/temp/pskill chrome',intern=T) !!
EDIT
Assuming you have multiple processes with the same name. You can use pslist to list the entire process with this name. Find the identifier of the process you want to kill, according to its elapsed time, then call pskill by id.
For example, here I want to kill, the last running chrome process
my.process <- system('c:/temp/pslist chrome ',intern=T)[-c(1:8)] my.process [1] "chrome 3852 8 38 1052 141008 0:01:58.108 1:43:11.547" [2] "chrome 5428 8 11 202 220392 0:02:08.092 1:43:11.359" [3] "chrome 6228 8 9 146 73692 0:01:58.467 1:43:00.091" [4] "chrome 6312 6 9 130 45420 0:00:08.704 1:17:30.153" [5] "chrome 360 6 9 127 29252 0:00:01.263 0:57:01.084" [6] "chrome 5032 6 9 126 29596 0:00:00.717 0:31:39.875" [7] "chrome 2572 8 9 120 23816 0:00:00.452 0:19:10.307"
source share