用于检测进程的shell脚本
来源:互联网 发布:linux创建用户指定id 编辑:程序博客网 时间:2024/05/01 23:23
用于检测进程的shell脚本
2010-07-07 10:38:08| 分类: Centos |字号 订阅
脚本一:
#!/bin/sh
program=XXXX #进程名
sn=`ps -ef | grep $program | grep -v grep |awk '{print $2}'` #获得进程端口号
if [ "${sn}" = "" ] #如果为空,表示进程未启动
then
nohup /home/oracle/XXXX & #后台启动进程
echo start ok !
else
echo running
fi
脚本二:
#!/bin/sh
ps -ef |grep ./FileServer > /dev/null 2>&1 #检测进程写入/dev/null
if [ $? -eq 0 ] #0为正常
then
echo logprocess run ok!
else
nohup /home/oracle/XXXX &
echo start ok !
fi
脚本三:
#!/bin/sh
count=`ps -fe |grep "a.out" | grep -v "grep" | wc -l`
if [ $count -lt 1 ]; then
/root/sh/restart.sh
脚本四:
PNAME="authd"
PATHNAME=/root/cauthd/build/
LENGTH=`ps -ef|grep "$PNAME"|grep -v grep|cut -b 49-200|wc -c `
if test $LENGTH -eq 0
then
cd $PATHNAME
nohup $PNAME >/dev/null
脚本五:
#! /bin/bash
echo "请输入进程名:"
read process
echo "你要查找的进程是 $process ,正在查找..."
ps > text1
grep "$process" text1
declare -i a=$?
if [ $a -eq 0 ]
then
echo "该进程存在"
else
echo "该进程不存在"
fi
2010-07-07 10:38:08| 分类: Centos |字号 订阅
脚本一:
#!/bin/sh
program=XXXX #进程名
sn=`ps -ef | grep $program | grep -v grep |awk '{print $2}'` #获得进程端口号
if [ "${sn}" = "" ] #如果为空,表示进程未启动
then
nohup /home/oracle/XXXX & #后台启动进程
echo start ok !
else
echo running
fi
脚本二:
#!/bin/sh
ps -ef |grep ./FileServer > /dev/null 2>&1 #检测进程写入/dev/null
if [ $? -eq 0 ] #0为正常
then
echo logprocess run ok!
else
nohup /home/oracle/XXXX &
echo start ok !
fi
脚本三:
#!/bin/sh
count=`ps -fe |grep "a.out" | grep -v "grep" | wc -l`
if [ $count -lt 1 ]; then
/root/sh/restart.sh
脚本四:
PNAME="authd"
PATHNAME=/root/cauthd/build/
LENGTH=`ps -ef|grep "$PNAME"|grep -v grep|cut -b 49-200|wc -c `
if test $LENGTH -eq 0
then
cd $PATHNAME
nohup $PNAME >/dev/null
脚本五:
#! /bin/bash
echo "请输入进程名:"
read process
echo "你要查找的进程是 $process ,正在查找..."
ps > text1
grep "$process" text1
declare -i a=$?
if [ $a -eq 0 ]
then
echo "该进程存在"
else
echo "该进程不存在"
fi
rm text1
检测进程 cpu mem
[code]
[root@test ~]# ps aux |awk -v OFS="\t" 'BEGIN{print "httpd"}/%MEM|httpd/{print $3,$4}'
httpd
%CPU %MEM
0.0 1.5
0.0 1.5
0.0 1.5
0.0 1.5
0.0 1.5
0.0 1.5
0.0 0.1
[/code]
获取当前内存状态的shell脚本
2009-11-17 15:54
#!/bin/sh
while true
do
echo `free | awk '{print $3}'` | awk '{print $2}' >a
str=`cat a`
echo $str
echo `free | awk '{print $2}'` | awk '{print $2}' >b
tot=`cat b`
echo $tot
#rc=`expr $str / $tot`
rate=`echo "scale=2;$str/$tot"|bc`
echo $rate
echo "-------"
sleep 1
done
- 用于检测进程的shell脚本
- 用于检测进程的shell脚本代码小结
- 用于检测进程的shell脚本代码小结
- [shell]对apache进程进行检测的脚本
- 监控进程的shell脚本
- shell脚本检测服务器进程并重启以及失败预警
- 检测域名有效期的 Shell 脚本
- 检测CPU利用率的Shell脚本
- shell脚本实现网络连接的检测
- shell脚本---回文检测
- shell 脚本 检测文件夹
- 一个用于批量下载网络图片的Shell脚本
- 一个用于批量下载网络图片的Shell脚本
- 定时检查进程的shell脚本
- 定时检查进程的shell脚本
- Shell写的一个进程监视脚本
- 好用的shell脚本 控制进程
- shell 脚本实现的守护进程
- HDU 4026
- Hash算法系列-简介
- 两个div块中的文字所占用的高度在不同浏览器中不一致,此时应设置两个div块中height和line-height
- Android UI 优化 使用<include/>和 <merge />标签
- 运用WCF来简化Ajax代码
- 用于检测进程的shell脚本
- source insight 3.5 如何增强阅读代码的性能
- Android Launcher View构架浅析
- EL表达式 (详解)
- Java 类集
- JAVA中iterator与add的顺序问题
- 学习计划于2011年9月10日
- AS3 - Web Service 类包
- Ubuntu 下安裝 GTK