一个清除BBS相关东东的Perl Scripts.
#! /usr/bin/perl -w
#
# Tools for clear BBS daemon
# Risker, BUAA, 2002/1/6
#
# It kill all processes owned by 'bbs', and clear BBS's SHM. When BBS
# need to be reboot, it's useful.
# Notice! Here, the BBS user is 'bbs'. Change it according to your BBS.
#
# check who run this
$bbsuid = `id -u bbs 2>&1`;
die "No user 'bbs'!\n" unless $bbsuid =~ /^\d/;
$runner = `id -u`;
chomp $bbsuid;
chomp $runner;
die "Only root or user 'bbs' (UID=$bbsuid) can do it!!!\n"
unless ($runner == $bbsuid || $runner == 0);
print "Are you sure to reboot BBS? [y/n]";
$ans = <STDIN>;
die "Cancel reboot.\n" unless ( $ans =~ /^y/i);
# kill process
print "\n---> Kill all processes owned by bbs daemon....\n\n";
# exclude the processes of mine and other BBS administrator
#
@pids = grep { /^\s*?\d+/ } `ps -u bbs`;
@a = grep { /\s+bash/ || /\s+sh/ || /\s+csh/ } @pids;
foreach (@a) {
/\s*\d+\s+(.+?)\s+/;
@pids = grep { ! /$1/ } @pids;
}
# kill them
foreach (@pids) {
/\s*(\d+)/;
next unless defined $1;
print "Kill process: $_";
qx / kill -9 $1 /;
}
# clear SHM
print "\n---> Clear SHM occupied by bbs....\n\n";
open INF, "ipcs | grep -e '^0x.* bbs ' |";
while(<INF>) {
@a = split /\s+/;
print "Clear SHM: $a[1] \n";
qx / ipcrm shm $a[1] /;
}
print "\nProgrammed by risker, BUAA, 2002/1/6. :)\n\n";
【 在 pipeline.bbs@bbs.pku.edu.cn (快乐的流水线) 的大作中提到: 】
: 嗯
: 具体怎么操作呀
: //thx
--
修改:risker FROM 211.71.3.205
FROM 211.71.3.205