zlingh

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

监控内存脚本

#!/bin/sh
echo -n "manager_mem:";
ps ux | grep manager.jar | grep -v grep | awk 'BEGIN{s=0}{s=s+$6}END{print s}';
echo -n "user_process:";
ps -U map H | wc -l;

 

ct执行重启脚本

#!/bin/bash
cd /home/map/manager;
#u=`ps ux | grep manager.jar | grep -v grep | awk 'BEGIN{s=0}{s=s+$6}END{printf s}'`
u=`ps uxH | grep manager.jar  | wc -l`
echo $u
#if [ $u -gt 6069392 ];then
if [ $u -gt 1500 ];then
#echo "memory bigger then 8069392, restart the program";
echo "thread bigger then 1500, restart the program";
ps aux|grep "manager.jar"|grep -v "grep" |awk '{print $2}'|xargs kill -9
sleep 1
nohup sh ./bin/start.sh </dev/null >/dev/null 2>&1 &
fi;

 

shell中 

> /dev/null < /dev/null 2>&1

分别什么意思

> /dev/null 输出重定向

2>&1 错误页重定向到标准输出

< /dev/null 把标准输入重定向,/dev/null这个文件作为读的时候有个特点,就是一读,马上就返回0,意味着文件结束了。这样在中控机执行的时候就可以马上推迟

 

shell 13问

http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=218853&page=7#pid1636825

posted on 2015-05-09 22:06  zlingh  阅读(182)  评论(0编辑  收藏  举报