linux开机自动运行auto_run_script.sh脚本
auto_run_script.sh文件内容
#!/bin/bash
source /etc/profile
echo "---------service starting.....-----------------------------" >> /home/service/auto_run_script.log
date >> /home/service/auto_run_script.log
nohup java -jar /home/service/xxxxxx.jar >> /home/service/auto_run_script.log 2>&1 &
echo "---------service start finished-----------------------------" >> /home/service/auto_run_script.log
auto_run_script.sh脚本使用说明:
1.在/home/目录下新建service目录
2.将auto_run_script.sh放到/home/service目录下
3.修改auto_run_script.sh文件nohup命令中jar包存放具体的目录
4.修改/etc/rc.d/rc.local,在此文件里添加:/home/service/auto_run_script.sh
命令为vi /etc/rc.d/rc.local,添加完后保存即可
备注:
1.检查执行该shell的服务器的环境变量有没有将JAVA_HOME/bin加入
2.执行auto_run_script.sh脚本相关的文件都需要使用chmod +x auto_run_script.sh修改文件权限

浙公网安备 33010602011771号