#!/usr/local/bin/perl

#This script kills all the running java and irserv processes

@ps_out = `ps -ef -o user,pid,args`;

foreach $line (@ps_out) {
  #splitting ps line to uname, pid and cmd
  ($user, $pid, @command_arr)  = split(' ', $line);
  $command = "@command_arr"; #merging all the command together

  if($user =~ webflow && 
     $command =~ /java *.*\.jigsaw\./) {
    print "kill -9 $pid";
    print " --> $command\n";
    `kill -9 $pid`
  }
}
