60 lines
1.4 KiB
Bash
60 lines
1.4 KiB
Bash
|
|
#!/bin/sh
|
||
|
|
|
||
|
|
#date:20191219
|
||
|
|
|
||
|
|
#禁止以root用户运行
|
||
|
|
curuser=`whoami`
|
||
|
|
if [ $curuser = "root1" ];then
|
||
|
|
echo "root Operation is not allowed!!"
|
||
|
|
exit -1
|
||
|
|
fi
|
||
|
|
|
||
|
|
#定义清除内存函数
|
||
|
|
function clear_all_shmkey(){
|
||
|
|
cd /data/home/mmog/center_server_900/runenv/msgq
|
||
|
|
sh clear.sh >/dev/null
|
||
|
|
|
||
|
|
ipcrm -M 1109007
|
||
|
|
ipcrm -M 11090010
|
||
|
|
ipcrm -M 11090012
|
||
|
|
ipcrm -M 11090014
|
||
|
|
ipcrm -M 11090011
|
||
|
|
ipcrm -M 1109005
|
||
|
|
ipcrm -M 2109003
|
||
|
|
ipcrm -M 3109003
|
||
|
|
|
||
|
|
ipcrm -M 11090050
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
#统计进程总数
|
||
|
|
proc_count=`ps -ef|grep 'a5game_zs_900\>'|grep -v grep|egrep 'team_svr|relation_svr|global_chat_svr|db_global_proxy|center_busd_svr' |wc -l`
|
||
|
|
|
||
|
|
# 打印error信息
|
||
|
|
function print_error_message() {
|
||
|
|
message=$1
|
||
|
|
echo -e "\033[31m${message}\033[0m"
|
||
|
|
}
|
||
|
|
# 打印info信息
|
||
|
|
function print_info_message() {
|
||
|
|
message=$1
|
||
|
|
echo -e "\033[36m${message}\033[0m"
|
||
|
|
}
|
||
|
|
|
||
|
|
#执行清除操作
|
||
|
|
print_info_message "---------------A5game_中顺_900服-------------"
|
||
|
|
if [ "${proc_count}" == "0" ];then
|
||
|
|
clear_all_shmkey >/dev/null 2>&1
|
||
|
|
print_info_message "-------------- 清除共享内存操作结束 --------------"
|
||
|
|
else
|
||
|
|
print_error_message "当前还有${proc_count}个进程正在运行"
|
||
|
|
print_error_message "请先停止正在运行的进程,再执行此操作"
|
||
|
|
print_error_message "--------------------------------------------------"
|
||
|
|
fi
|
||
|
|
|
||
|
|
#清除空闲内存
|
||
|
|
sleep 2
|
||
|
|
ipcs -m|grep ^0x |awk '$6==0{print $2}'|xargs -I {} ipcrm -m {} >/dev/null 2>&1 || echo
|
||
|
|
|