当前位置: 技术问答>linux和unix
将tomcat设为Linux系统服务自启动问题
来源: 互联网 发布时间:2016-11-03
本文导语: 1、在/etc/init.d 下创建一tomcat启动脚本 2、chkconfig --add tomcat 3、service tomcat start 这时会出现env: /etc/init.d/tomcat:No such file or directory tomcat服务无法启动,难道还需要其它配置吗?高手帮忙看一下吧 脚本: #!/bin/...
1、在/etc/init.d 下创建一tomcat启动脚本
2、chkconfig --add tomcat
3、service tomcat start
这时会出现env: /etc/init.d/tomcat:No such file or directory
tomcat服务无法启动,难道还需要其它配置吗?高手帮忙看一下吧
脚本:
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
. /etc/init.d/functions
# source networking configuration.
. /etc/sysconfig/network
RETVAL=0
export JAVA_HOME=/usr/java/jdk1.6.0_23
export CATALINA_HOME=/usr/tomcat6
export CATALINA_BASE=/usr/tomcat6
export CATALINA_TMPDIR=/usr/tomcat6/temp
TOMCATUSER=tomcat
start()
{
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
/bin/su $TOMCATUSER -c $CATALINA_HOME/bin/startup.sh
RETVAL=$?
echo " OK"
return $RETVAL
fi
}
stop()
{
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
/bin/su $TOMCATUSER -c $CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
sleep 1
ps -fwwu tomcat | grep apache-tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9
echo " OK"
# [ $RETVAL -eq 0 ] && rm -f /var/lock/...
return $RETVAL
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo $"Restaring Tomcat"
$0 stop
sleep 1
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
2、chkconfig --add tomcat
3、service tomcat start
这时会出现env: /etc/init.d/tomcat:No such file or directory
tomcat服务无法启动,难道还需要其它配置吗?高手帮忙看一下吧
脚本:
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts tomcat
# /etc/init.d/tomcatd
# Tomcat auto-start
# Source function library.
. /etc/init.d/functions
# source networking configuration.
. /etc/sysconfig/network
RETVAL=0
export JAVA_HOME=/usr/java/jdk1.6.0_23
export CATALINA_HOME=/usr/tomcat6
export CATALINA_BASE=/usr/tomcat6
export CATALINA_TMPDIR=/usr/tomcat6/temp
TOMCATUSER=tomcat
start()
{
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
/bin/su $TOMCATUSER -c $CATALINA_HOME/bin/startup.sh
RETVAL=$?
echo " OK"
return $RETVAL
fi
}
stop()
{
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
/bin/su $TOMCATUSER -c $CATALINA_HOME/bin/shutdown.sh
RETVAL=$?
sleep 1
ps -fwwu tomcat | grep apache-tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9
echo " OK"
# [ $RETVAL -eq 0 ] && rm -f /var/lock/...
return $RETVAL
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo $"Restaring Tomcat"
$0 stop
sleep 1
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
|
1、在/etc/init.d 下创建一tomcat启动脚本
----------------------
你确认你创建的文件名字叫tomcat吗?
有执行权限吗?
----------------------
你确认你创建的文件名字叫tomcat吗?
有执行权限吗?
|
一般的错误是lz没有赋予可执行权限
chmod u+x 文件
chmod u+x 文件
|
你的启动脚本是不是没有可执行权限,试试chmod u+x /etc/init.d/tomcat给启动脚本加上可执行权限