vim /etc/rc.d/rc.local
打开后用下文覆盖即可
#!/bin/sh
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
export JAVA_HOME=/opt/jdk1.7.0_71
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_HOME=/opt/apache-tomcat-7.0.54
#tomcat自启动
/opt/apache-tomcat-7.0.54/bin/startup.sh
#其他程序自启动例子
#/usr/bin/程序名
保存,然后重启电脑即可