增加服务文件
进入服务文件目录:
1
|
cd /etc/systemd/system/
|
创建服务文件:(文件名对应项目名,可自定义)
编辑内容
1 2 3 4 5 6 7 8 9 10
|
[Unit] Description=apps After=syslog.target
[Service] ExecStart=/usr/software/jdk1.8.0_131/bin/java -jar /var/apps/my-apps.jar Restart=always
[Install] WantedBy=multi-user.target
|
其它项目使用只要修改 Description
和 ExecStart
即可。
服务操作
启动服务
1
|
systemctl start my-apps.service
|
停止服务
1
|
systemctl stop my-apps.service
|
服务状态
1
|
systemctl status my-apps.service
|
开机启动
1
|
systemctl enable my-apps.service
|
开机禁用
1
|
systemctl disable my-apps.service
|
查看服务是否开机启动
1
|
systemctl is-enabled my-apps.service
|
项目日志
1
|
journalctl -u my-apps.service
|
近期评论