您的位置:首页 > 其它

15.2.1_介绍函数式动画

2011-12-12 20:33 85 查看
#!/bin/bash

#chkconfig:35 99 99

#description: Monitor the usage of disk

proc="diskmond"

# test parameters syntax

if [ $# -eq 0 ]

then

echo "参数不正确 例:diskmond [start,restart,stop,status]"

exit 1

fi

function start()

{

if [ -e /var/run/$proc.pid ]

then

echo "磁盘监控程序已经在运行(pid `cat /var/run/$proc.pid`)"

else

echo "磁盘监控程序正在启动中...."

./etc/rc.d/init.d/diskmon &

if [ $? -eq 0 ]

then

pidof -s -x diskmond >/var/run/diskmond.pid

echo "磁盘监控程序启动成功(pid `cat /var/run/$proc.pid`)~"

else

echo "磁盘监控程序发生未知错误,启动失败!"

exit 1

fi

fi

}

function stop()

{

if [ -e /var/run/$proc.pid ]

then

echo "正在停止磁盘监控程序...."

kill -9 `cat /var/run/"$proc".pid`

if [ $? -eq 0 ]

then

echo "磁盘监控程序已经停止"

else

echo "磁盘监控程序停止发生错误(失败)."

fi

rm -f /var/run/$proc.pid

else

echo "磁盘监控程序没有开启"

fi

function status()

{

if [ -e /var/run/$proc.pid ]

then

echo "磁盘监控程序(pid `cat /var/run/${proc}.pid`)正在运行"

else

echo "磁盘监控程序没有开启"

fi

}

function restart()

{

stop

start

}

case $1 in

start)

start

;;

stop)

stop

;;

status)

status

;;

restart)

restart

;;

*)

echo "参数不正确 例:diskmond [start,restart,stop,status]"

exit 1

;;

esac

本文出自 “天雪泪” 博客,请务必保留此出处http://hongjun.blog.51cto.com/445761/390731
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: