Ubuntu16.04 设置jar开机自启脚本
1.编写脚本 后缀 ".sh"
#! /bin/sh ### BEGIN INIT INFO # Provides: start-adb-connect-manager # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: ### END INIT INFO echo "jar 包开始部署" nohup java -jar /root/ruoyi.jar > /dev/null 2>&1 & echo "ok is successful"
2.window上编写需要替换 /r 否则会报错
方法1: 直接替换
sed -i 's/\r//' youwei.sh
方法2: 安装dos2unix
yum install -y dos2unix
dos2unix youwei.sh