H
Hugh Kang
I just started learning Perl and I am trying to do followings;
ps -ef | grep java >pidfile
In pidfile, there are 3 PIDs for weblogic processes.
root 1769 1758 TS 0 0 17:55:26 vt02 44:38
/opt/java2-1.3.1/bin/./../bin/x86at/native_threads/java -Xms512m
-Xmx512m -Dweb
root 27464 27453 TS 29 0 09:15:55 vt04 91:55
/opt/java2-1.3.1/bin/./../bin/x86at/native_threads/java -Xms1024m
-Xmx1024m -Dw
root 27533 27522 TS 49 0 09:21:45 vt03 2:35
/opt/java2-1.3.1/bin/./../bin/x86at/native_threads/java -Xms32m
-Xmx200m -Dwebl
What I want is get the largest PID which is 27533 in this case, and
then
kill -3 the PID.
So I made a simple one for this:
#!/usr/bin/perl
#
# This is a test script to get wls managed server pid
#
#
open(JAVAPIDS,"pidfile") or die "can't open input file:$!\n";
$pidcnt=0;
while($line=<JAVAPIDS>) {
# ($user,$pid1,$pid2,$it4,$it5,$it6,$it7,$it8,$it9,$it10,$it11,$it12,$it13,$it14,$it15)=split("
",$line);
($user,$pid1)=split(" ",$line);
$pidfile{$pid1}=$pid1;
$pid_comp[$pidcnt]=$pidfile{$pid1};
# print "pid$pidcnt : $pid_comp[$pidcnt] \n";
if ($pidcnt gt 0) {
if ($pid_comp[0] < $pid_comp[$pidcnt]) {
$pid_comp[0] = $pid_comp[$pidcnt];
}
}
$pidcnt++;
}
print "pidcnt : $pidcnt \n";
print "Largest PID for java is : $pid_comp[0] \n";
------------------------------------------
Q1) How do I do 'kill -3 $pid_comp[0] in this script?
Q2) Is there any way that I can do the followings:
In a Unix script,
ps -ef |grep java >pidfile
../perl_script
....
....
kill -3 $pid_comp[0]
Q3) Any other way to get what I want?
Can anyone help me out with this issue please?
Many thanks in advance!
Hugh
ps -ef | grep java >pidfile
In pidfile, there are 3 PIDs for weblogic processes.
root 1769 1758 TS 0 0 17:55:26 vt02 44:38
/opt/java2-1.3.1/bin/./../bin/x86at/native_threads/java -Xms512m
-Xmx512m -Dweb
root 27464 27453 TS 29 0 09:15:55 vt04 91:55
/opt/java2-1.3.1/bin/./../bin/x86at/native_threads/java -Xms1024m
-Xmx1024m -Dw
root 27533 27522 TS 49 0 09:21:45 vt03 2:35
/opt/java2-1.3.1/bin/./../bin/x86at/native_threads/java -Xms32m
-Xmx200m -Dwebl
What I want is get the largest PID which is 27533 in this case, and
then
kill -3 the PID.
So I made a simple one for this:
#!/usr/bin/perl
#
# This is a test script to get wls managed server pid
#
#
open(JAVAPIDS,"pidfile") or die "can't open input file:$!\n";
$pidcnt=0;
while($line=<JAVAPIDS>) {
# ($user,$pid1,$pid2,$it4,$it5,$it6,$it7,$it8,$it9,$it10,$it11,$it12,$it13,$it14,$it15)=split("
",$line);
($user,$pid1)=split(" ",$line);
$pidfile{$pid1}=$pid1;
$pid_comp[$pidcnt]=$pidfile{$pid1};
# print "pid$pidcnt : $pid_comp[$pidcnt] \n";
if ($pidcnt gt 0) {
if ($pid_comp[0] < $pid_comp[$pidcnt]) {
$pid_comp[0] = $pid_comp[$pidcnt];
}
}
$pidcnt++;
}
print "pidcnt : $pidcnt \n";
print "Largest PID for java is : $pid_comp[0] \n";
------------------------------------------
Q1) How do I do 'kill -3 $pid_comp[0] in this script?
Q2) Is there any way that I can do the followings:
In a Unix script,
ps -ef |grep java >pidfile
../perl_script
....
....
kill -3 $pid_comp[0]
Q3) Any other way to get what I want?
Can anyone help me out with this issue please?
Many thanks in advance!
Hugh