vi /etc/init.d/ami
内容:
#!/bin/bash
# chkconfig: - 64 36
# description:  asterisk ami monitor
# processname: ami
# Source function library.
. /etc/rc.d/init.d/functions
prog="ami"
start()
{
        cd /root/ami
        java -jar ami.jar
}
stop()
{
        pid=`ps aux|grep -v grep|grep  "ami.jar"|awk '{print $2}'`
        if  [ "$pid" ];      then
                kill $pid
        fi
}
restart()
{
        stop
        start
}
status()
{
        pid=`ps aux|grep -v grep|grep  "ami.jar"|awk '{print $2}'`
        if  [ "$pid" ];      then
                echo $pid "AMI is runnig ......"
        fi
}
# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status
    ;;
  restart)
    restart
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart}"
    exit 1
esac
exit $?
chmod +x ami
chkconfig --add ami
chkconfig --level 2345 ami on
为什开机不执行,
我在sh下输入命令
service ami start可以启动程序
                  	
				

sokaka 于 2011-08-04 15:54:19发表:
支持顶下,完全不懂
toby-light 于 2011-08-04 11:47:05发表:
路过,不是太懂。正在学习中。^_^
zzcva 于 2011-08-04 08:46:36发表:
不懂的路过
qq22049023 于 2011-08-03 20:37:54发表:
脚本没有错,但是怎么设让他在mysql启动完后再运行这个程序?
mysql的这一行是这个# chkconfig: - 64 36
erlengzhi2 于 2011-08-03 19:41:55发表:
帮LZ顶上去同问,哈哈,这个要高手来回答了