Linux开机启动指定服务(Tomcat、Openfire)

doITwhat 2018-01-09

近期需要在centos中开机启动Openfire,正常的思路是在/etc/rc.local添加启动脚本,效果如下

/home/user/openfire-3.7.1/bin/openfire start

 结果报错如下,主要是环境变量在root用户下没有配置。

No suitable Java Virtual Machine could be found on your system.
The version of the JVM must be at least 1.5.
Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
You can also try to delete the JVM cache file /root/.install4j

 解决思路:

在user用户下新增启动脚本/home/user/openfire-3.7.1/bin/start.sh, 然后在/etc/rc.local中,添加使用制定用户运行脚本

/etc/rc.local文件中添加脚本如下:

su - user-c /home/user/openfire-3.7.1/bin/start.sh

 /home/user/openfire-3.7.1/bin/start.sh文件内容如下:

#/home/user/openfire-3.7.1/bin/start.sh
/home/user/openfire-3.7.1/bin/openfire start

相关推荐

moyazheng / 0评论 2013-06-29