新建startup.sh文件

在系统中安装JDK及配置好环境变量

1
2
3
4
5
6
7
#!/bin/sh
export JAVA_HOME=/usr/java/jdk1.8.0_141
export PATH=$JAVA_HOME/bin:$PATH
cd /devdata/www/.../.../
# ***** 代表文件(类)名
nohup java -jar ./....war com.***.****Application >/dev/null 2>&1 &
touch /data/wwwroot/bank/log.log

编辑rc.local文件

1
sudo vi /etc/rc.d/rc.local

在文本最后面添加以下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

# 这里可能有其它自启程序请勿删除 ... #

nohup sh /devdata/www/****/startup.sh >/devdata/www/****/startup-log.txt 2>&1
nohup sh /devdata/www/****/***/startup.sh >/devdata/www/****/startup-log.txt 2>&1

/sbin/service crond start
touch /var/lock/subsys/local

配置保存完成之后重启系统

1
sudo reboot