在做oracle数据库管理的时候,经常会有用户遇到超过最大进程数的错误,表现为新的连接无法登入数据库。一致提示超过最大的process数 。其实这个问题,如果用户是测试环境,好解决。直接关闭数据库或者直接kill掉所有的“LOCAL=NO”的进程。
但是很多情况是,用户无法接受停机,或者kill掉所有的远端连接。基于以上情况,写了如下脚本
#!/usr/bin/perl
#write by wulei
#get the first parameter
$arg1="";
chomp($arg1);
while($arg1 eq "")
{
print "please input your first parameter:";
$arg1=;
chomp($arg1);
if($arg1 ne ""){
@temp1=`ps -eo lstart,pid,args | grep '$arg1' | grep -v grep`;
$process_count=`ps -eo lstart,pid,args | grep '$arg1' | grep -v grep | wc -l`;
chomp($process_count);
if($process_count eq "0")
{
$arg1="";
print "we got 0 processes,please retry!\n";
next;
}
print "We will kill $process_count(count) processes\n";
print "All the processes list below!!!!!!!!!!!!!!!!!\n";
print "#############################################################\n";
print @temp1;
}
chomp($arg1);
}
#get the second parameter
$arg2="";
chomp($arg2);
while($arg2 eq "")
{
print "\n";
print "\n";