Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 操作系统 > Linux > 测试数据库连接的Shell脚本
【标  题】:测试数据库连接的Shell脚本
【关键字】:Shell
【来  源】:http://www.cublog.cn/u/5591/showart.php?id=180921

测试数据库连接的Shell脚本

Your Ad Here
为了开机时以普通用户自动启动测试程序,并且以后每天测试一遍,再编写以下两个脚本。
第一个脚本:
# /home/mishuang/bin/start-stop

PID_FILE=/tmp/monitor.pid

case "$1" in
        start)
                if [ -f $PID_FILE ]
                then
                        echo "monitor already started!"
                        exit 1
                fi
                echo $$ > $PID_FILE
                while true
                do
                        seconds=$((24*60*60))
                        sleep $seconds
                        /home/mishuang/bin/monitor
                done
                ;;
        stop)
                if [ -f $PID_FILE ]
                then
                        pid=`cat $PID_FILE`
                        kill -9 $pid
                        echo "remove pid file"
                        rm -f $PID_FILE
                else
                        echo "monitor already terminated!"
                fi
                ;;
        restart)
                $0 stop
                sleep 1
                $0 start
                ;;
        *)
                printf "Usage: $0 {start|stop|restart}\n" >&2
                exit 1
                ;;
esac
exit 0

第二个脚本:
# /etc/init.d/monitor

case "$1" in
  start)
    su - mishuang /home/mishuang/bin/start-stop start &
    ;;
  stop)
    su - mishuang /home/mishuang/bin/start-stop stop
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    printf "Usage: $0 {start|stop|restart}\n" >&2
    exit 1
    ;;
esac
exit 0

最后chkconfig monitor on

curl突破限制的一些用法:【上一篇】
shell中几个很有趣的例子:【下一篇】
【相关文章】
  • 两个可用于webshell提权的EXP和1个内部版06040的EXP
  • 学习shell的感受
  • shell编程笔记8----grep家族
  • shell编程笔记6----命令执行顺序
  • shell编程笔记7----正则表达式
  • E680I/GE和A780的SHELL命令对比分析
  • shell十三问
  • 将MySQL数据库直接转换为XML文件的Shell脚本
  • 放一下自己的拙作——《用Webshell做隐藏BBS管理员》
  • 将MySQL数据库直接转换为XML文件Shell脚本
  • 【随机文章】
  • TCP/IP Problem Determination
  • 手机的中查询
  • FreeBSD 上使用Kerberos 5认证
  • 只度游戏更新+wsu
  • 获取电子邮箱密码的VC++代码
  • Subdivision Emulation下的纹理处理(2)
  • 浅析GLib - 宋国伟
  • 《解剖PetShop》系列之六
  • 四大漏洞入侵博客
  • Solaris 常见问题解决方法
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.