拓冰建站拓冰建站
首页 / 资讯中心 / 正文

Linux 服务管理——systemctl 与开机自启

systemctl 是现代 Linux 管理服务的标准方式。这篇讲如何把 SpringBoot 注册为系统服务。一、systemctl 常用命令systemctl start myapp# 启动systemctl stop myapp# 停止systemctl restart myapp# 重启systemctl status myapp# 查看状态systemctlenablemyapp# 开机自启systemctl disable myapp# 取消自启systemctl daemon-reload# 重载配置二、注册 SpringBoot 服务# /etc/systemd/system/seckill.service [Unit] DescriptionSeckill System Afternetwork.target mysql.service redis.service [Service] Typesimple Userroot WorkingDirectory/opt/seckill ExecStart/usr/bin/java -jar /opt/seckill/app.jar --spring.profiles.activeprod Restarton-failure RestartSec10 [Install] WantedBymulti-user.target# 启用sudosystemctl daemon-reloadsudosystemctlenableseckillsudosystemctl start seckill三、查看日志journalctl-useckill-f# 实时跟踪日志journalctl-useckill--since1 hour ago# 最近1小时journalctl-useckill-perr# 只看错误级别 觉得有用的话点赞 关注【张老师技术栈】吧
分享:

看完干货,该让你的企业上线了

免费需求沟通 · 48 小时内出具建站方案 · 河南本地可上门