Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 34 lines (28 sloc) 562 Bytes
#!/usr/bin/perl
# Examples
#
# stop-sheepdog 0 3 4
# stop-sheepdog [0-100]
@index_list = @ARGV;
if (@index_list == 0) {
@index_list = (0);
}
$dport = 7000;
foreach $proc (`ps -o pid,args -C sheep`) {
foreach $i (@index_list) {
if ($i =~ /\[(\d+)-(\d+)\]/) {
&stop_dog($dport + $_) foreach ($1..$2);
} else {
&stop_dog($dport + $i);
}
}
}
sub stop_dog {
my ($port) = @_;
if ($proc =~ /port $port/) {
$proc =~ s/^\s+(.*)/$1/;
($pid, @cmd) = split /\s/, $proc;
print "kill -9 $pid (@cmd)\n";
system "kill -9 $pid";
}
}
Jump to Line
Something went wrong with that request. Please try again.