On 02.12.09 07:30 raj kumar wrote:
When i ran tomcat and shut it down my java process is not closing along with
shutdown.i need to kill it explicitly. So I would like to know how to
identify the java process of the logged in user who started the server. so
that i can kill the process id from the shutdown.sh script itself. Please
Hi, this is how I do it (extracted from a perl script):
if ($uname eq "Linux") {
$cmd = "pgrep -lf -u $user java | grep -v grep | grep '$name'| awk '{print
\$1}'";
} elsif ($uname eq "Solaris") {
$cmd = "/usr/ucb/ps auxww | grep '^$user' | grep java | grep -v grep | grep
-w '$name' | awk '{print \$2}'";
}
open(PIDS, "$cmd|");
my @pids = <PIDS>;
close(PIDS);
foreach (@pids) {
if (/^(\d+)/) {
my $pid = $1;
if (`ps -o fname -p $pid` =~ /java/) {
printf STDERR "Killing process %d ..\n", $pid;
kill(15, $pid);
sleep(5);
kill(9, $pid);
}
}
}
Cheers,
Wesley
--
Online Broadband BV, http://www.online.nl, http://www.euronet.nl
Wesley Schwengle, System Administrator, IT Operations (Database/Application
Management)
Muiderstraat 1, PO BOX 10241, 1001 EE Amsterdam, T: +31 20 5355555, F: +31 20
5355749
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]