由于软件占用资源较大,tomcat经常停止服务,怎么在tomcat停止服务后让其自动重启.我linux不熟,有没有写好的代码,或软件,谢谢!

解决方案 »

  1.   

    定时去监听tomcat用的端口号,如果没响应的话,就重启tomcat
      

  2.   

    1.linux下的计划任务cron
    2.编写shell脚本,每隔一段时间查看一次状态,如果是关闭的就重启。
      

  3.   

    个人知识范畴内的解决方案
    起个定时器,定时检查对应端口,如果端口不存在,调用linux命令启动服务
      

  4.   

    这个可用,但我想楼主对shell脚本也不是很清楚。最好给他来一段吧
      

  5.   

    建一个 Bash Shell 脚本:#!/bin/bash
    c=$(netstat -anpt | grep LISTEN | grep :8080\\b | wc -l)
    if [ $c -lt 1 ]
    then
      ## 重启 tomcat
      sh /tomcat/bin/startup.sh
    fi存为 monitor.sh,再用 chmod +x monitor.sh 改为可执行crontab -e 加一行:*/5 * * * * /home/xxxx/monitor.sh > /dev/null 2>&1每 5 分钟监测一次。
      

  6.   

    这里要改一下:#!/bin/bash
    c=$(netstat -anpt | grep LISTEN | grep :8080\\b | wc -l)
    if [ $c -lt 1 ]
    then
      ## 重启 tomcat
      sh /tomcat/bin/startup.sh &
    fi加个 & 让其在后台运行
      

  7.   


    严重支持!!看来火龙哥LINUX用的挺熟悉啊。