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

时间:2017-03-03 15:26:34

标签: tomcat centos boot

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

1 个答案:

答案 0 :(得分: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
相关问题