一、安装systemd
# yum
yum install systemd
# apt
apt install systemd
二、内容
使用文本编辑器,如 vim 创建并编辑 nexus.service 文件。
vim /etc/systemd/system/nexus.service
[Unit]
# 服务名称,可自定义
Description = nexus server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
# 启动nexus的命令
ExecStart = /opt/nexus/nexus3/bin/nexus run
[Install]
WantedBy = multi-user.target
使用 systemd 命令,管理 nexus。
#启动
systemctl start nexus
#停止
systemctl stop nexus
#重启
systemctl restart nexus
#查看状态
systemctl status nexus
#开机自启
systemctl enable nexus