配置Ubuntu Server,上面装了一Tomcat7,希望在服务器电源打开后,希望没有登录的情况下也可以自动启动Tomcat
1.编写启动文件/etc/init.d/tomcat7 tomcat7文件内容如下
#!/bin/sh case $1 in start) sh /opt/apache-tomcat-7.0.27/bin/startup.sh ;; stop) sh /opt/apache-tomcat-7.0.27/bin/shutdown.sh ;; restart) sh /opt/apache-tomcat-7.0.27/bin/shutdown.sh sh /opt/apache-tomcat-7.0.27/bin/startup.sh ;; *) echo ‘Usage:tomcat7 start|stop|restart‘ ;; esac exit 0
2.把/etc/init.d/tomcat7设置成可执行
sudo chmod +x /etc/init.d/tomcat7
3.将tomcat7加入服务
sudo update-rc.d tomcat7 defaults
时间: 2024-10-10 13:53:29