ubuntu22.04开机自启动Eureka服务

ubuntu22.04开机自启动Eureka服务

1、创建启动脚本eurekaService.sh

shell 复制代码
#我们把启动脚本放在/usr/software目录下
cd /usr/software
vim eurekaService.sh

eurekaService.sh内容为

shell 复制代码
#!/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"

2、赋予可执行权限

shell 复制代码
chmod 777 eurekaService.sh

3、新建要启动的Eureka服务文件

shell 复制代码
#新建要启动的服务文件
vim /etc/systemd/system/eureka.service

eureka.service内容为

shell 复制代码
[Unit]
Description=this is eurekaService 
After=network.target
[Service]
Type=forking
ExecStart=/usr/software/eurekaService.sh  #指定上面创建的脚步文件路径
[Install]
WantedBy=multi-user.target  #多用户

4、启动Eureka服务

shell 复制代码
#让系统获取到你刚自定义的service文件并设置开机启动
systemctl daemon-reload
systemctl start eureka.service

systemctl enable eureka.service

#查看日志
systemctl status eureka.service
相关推荐
leijiwen8 小时前
Bsin-PaaS(毕昇)——LinkLifeVerse OS 的产业智能工程底座
云原生·云计算·paas
吠品19 小时前
PHP里取月份最后一天的几种方式
java·开发语言·eureka
her_heart21 小时前
ChatGPT 5.6 实战:用 AI 做云成本治理,从账单复盘到 K8s 优化
人工智能·云原生·chatgpt·kubernetes·测试用例
DolphinScheduler社区1 天前
Apache DolphinScheduler 6 月治理优化,补齐调度运维全链路细节
大数据·运维·云原生·apache·海豚调度
AOwhisky2 天前
Python 学习笔记(第三期)——流程控制:条件判断与循环结构
运维·笔记·python·学习·云原生·流程控制·循环
Waay2 天前
Linux 三个核心环境变量配置文件、作用域、生效方式完整梳理
linux·运维·学习·云原生·容器
SelectDB2 天前
云数仓费钱?用 SelectDB Serverless 三步配出秒级弹性,最高降本 70%
数据库·云原生·数据分析
CHrisFC2 天前
2026-07-15-csdn-硕晟LIMS微服务架构设计
微服务·云原生·架构
长不胖的路人甲2 天前
微服务限流
微服务·云原生·架构