1. 编写启动脚本
脚本存放位置随意,本例保存在了/etc/rc.d/init.d/file-preview-server.sh
1 2 3 4 5 6 7 8 9 | # !/bin/bash # program # file preview server start export JAVA_HOME= /opt/jdk8 export JRE=$JAVA_HOME /jre export CLASSPATH=$JAVA_HOME /lib :$JRE /lib :. export PATH=$JAVA_HOME /bin/ :$JRE /bin :$PATH nohup java -jar /root/file-preview-server/file-preview-server .jar > /root/file-preview-server/stdout .log & |
2. 给/etc/rc.d/init.d/file-preview-server.sh文件添加执行权限
1 | chmod +x /etc/rc .d /init .d /file-preview-server .sh |
3. 给/etc/rc.d/rc.local文件添加执行权限
1 | chmod +x /etc/rc .d /rc . local |
4. 编辑/etc/rc.d/rc.local文件
在文件末尾添加如下语句
1 | su - root -c '/etc/rc.d/init.d/file-preview-server.sh' |
重启机器查看进程,如有相关进程即说明设置成功!!!