ljr/ljcom/bin/hkill

22 lines
313 B
Plaintext
Raw Permalink Normal View History

2019-02-05 21:49:12 +00:00
#!/usr/bin/perl
#
# <LJDEP>
# prog: ps, grep
# </LJDEP>
use strict;
my $prog = shift @ARGV;
exit unless ($prog =~ /^[\w\.\/]+$/);
my @procs = `ps awx | grep $prog | grep -v grep | grep -v hkill`;
foreach (@procs)
{
next unless (/^\s*(\d+)\s/);
my $pid = $1;
print $pid, "\n";
kill 1, $pid;
}