在/etc/rc.local 添加如下内容
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
cd /home/test/jar #jar包路径
nohup java -jar 1.jar > 1.txt &
cd /home/test/jar #jar包路径
nohup java -jar 2.jar > 2.txt &
exit 0
重启电脑
reboot
ps命令查看
ps -ef | grep jar
xxx@xxx-PC2:~/linux/jar4$ ps -ef | grep jar
root 1511 1 99 14:08 ? 00:24:50 java -jar 1.jar
root 1512 1 2 14:08 ? 00:00:42 java -jar 2.jar
xxx+ 2913 2394 0 14:33 pts/19 00:00:00 grep --color=auto jar