搬运之前的笔记,记不清具体细节,实际遇到了再完善吧
安装
sudo apt-get update
sudo apt-get install systemd
创建服务
sudo vim /etc/systemd/system/test.service
WebApi
安装donet6
sudo apt-get update
sudo apt upgrade
sudo apt-get install -y dotnet-sdk-6.0
创建服务
sudo vim /etc/systemd/system/webapi.service
[Service]
WorkingDirectory=/home/tim/webapi
ExecStart=/usr/bin/dotnet /home/tim/webapi/WebApplication1.dll
#自动重启当前服务间隔秒
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=webapi-service
User=tim
[Install]
WantedBy=multi-user.target
#该服务所在的Target
CS1.6服务器
sudo vim /etc/systemd/system/cs.service
[Unit]
Description=cs 1.6 server
[Service]
Type=simple
User=tim
WorkingDirectory=/data/amuse/steam/cs16
ExecStart=/usr/bin/bash hlds_run -game cstrike +port 27015 +map de_dust2 +maxplayers 16
Restart=always
[Install]
WantedBy=multi-user.target
基本操作
开机启动
sudo systemctl enable test.service
sudo systemctl disable test.service
启动
sudo systemctl start test.service
关闭
sudo systemctl stop test.service
??
作用没弄清
sudo systemctl daemon-reload
状态
sudo systemctl status test.service
日志
查看日志
journalctl -fu test.service
日志大小
journalctl --disk-usage
日志管理
配置路径
/etc/systemd/journald.conf
重启日志
日志配置修改后需要重启
sudo systemctl restart systemd-journald
评论