使用不同的用户重启时启动Tomcat

问题描述 投票:0回答:1

哪个是在重启时自动启动Tomcat的最快方法,而不使用root用户(我为其创建了一个名为'openam'的特定用户)并且没有使用JSVC。我正在运行Centos 6。

tomcat centos boot
1个回答
0
投票

对于任何人,我在/etc/init.t/tomcat中设置它

#!/bin/sh

# Purpose: Start or stop the Tomcat service.
# chkconfig: 345 95 5
# Check the path of Tomcat and set enviorment variables as follows in the .bashrc profile
export CATALINA_HOME="/path/tomcat"
export CATALINA_BASE="/path/tomcat"
JAVA_HOME="/usr/java/jdk1.8.0_131"
export JAVA_HOME

case $1 in
start)
su user -c /path/tomcat/bin/startup.sh
;;
stop)
su user -c /path/bin/shutdown.sh
;;
restart)
su user -c /path/tomcat/bin/shutdown.sh
su user -c /path/tomcat/bin/startup.sh
;;
esac
exit 0

其中user是您的初创用户。然后

chkconfig --add tomcat
© www.soinside.com 2019 - 2024. All rights reserved.