#我们把启动脚本放在/usr/software目录下
cd /usr/software
vim eurekaService.sh
eurekaService.sh内容为
#!/bin/sh
# this is a eurekaService shell to startup at the mechian power on.
echo "eurekaServer-0.0.1-SNAPSHOT.jar service start loading..."
nohup java -jar /usr/software/eurekaServer-0.0.1-SNAPSHOT.jar > /usr/software/log.txt 2>&1 &
echo "eurekaService loads successful"
chmod 777 eurekaService.sh
#新建要启动的服务文件
vim /etc/systemd/system/eureka.service
eureka.service内容为
[Unit]
Description=this is eurekaService
After=network.target
[Service]
Type=forking
ExecStart=/usr/software/eurekaService.sh #指定上面创建的脚步文件路径
[Install]
WantedBy=multi-user.target #多用户
#让系统获取到你刚自定义的service文件并设置开机启动
systemctl daemon-reload
systemctl start eureka.service
systemctl enable eureka.service
#查看日志
systemctl status eureka.service