Tomcat设置普通用户启动

新建用户tomcat,该用户不能登录

useradd tomcat -s '/sbin/nologin'
chown -R tomcat:tomcat /usr/local/tomcat/
chmod -R 744  /usr/local/tomcat

# 判断用户是否存在
ret=`id -u tomcat >& /dev/null`
if [ $? -ne 0 ];then
   echo "not exist"
fi

将/usr/local/tomcat/bin/startup.sh、shutdown.sh更名

mv /usr/local/tomcat/bin/startup.sh /usr/local/tomcat/bin/startup_.sh
mv /usr/local/tomcat/bin/shutdown.sh /usr/local/tomcat/bin/shutdown_.sh

新建脚本startup.sh、shutdown.sh

# startup.sh
#!/bin/bash
usermod -s /bin/bash tomcat
su - tomcat -c /usr/local/tomcat_web/bin/startup_.sh
usermod -s /sbin/nologin tomcat

# shutdwon.sh
#!/bin/bash
usermod -s /bin/bash tomcat
su - tomcat -c /usr/local/tomcat_web/bin/shuwdown_.sh
usermod -s /sbin/nologin tomcat

加入开机自启

/usr/local/tomcat/bin/startup.sh >> /etc/rc.local

原文链接http://www.cnblogs.com/qq931399960/p/9152201.html

上一篇:云原生时代,谁是容器的最终归宿?


下一篇:BREW SDK 九大功能之位置服务