Linux - Systemd守护进程

Tim
2024-10-10
点 赞
0
热 度
34
评 论
0

文章摘要

智阅GPT

搬运之前的笔记,记不清具体细节,实际遇到了再完善吧

安装

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

SystemMaxUse

指定日志在持久性存储中可使用的最大磁盘空间

SystemMaxUse=500M

SystemKeepFree

指定在将日志条目添加到持久性存储时,日志应留出的空间量

SystemKeepFree=100M

SystemMaxFileSize

控制单个日志文件在被轮换之前在持久性存储中可以增长到多大

SystemMaxFileSize=100M

RuntimeMaxUse

指定在易失性存储中可以使用的最大磁盘空间(在 /run 文件系统内)

RuntimeMaxUse=100M

RuntimeKeepFree

指定将数据写入易失性存储(在 /run 文件系统内)时为其他用途预留的空间数量

RuntimeMaxUse=100M

RuntimeMaxFileSize

指定单个日志文件在被轮换之前在易失性存储(在 /run 文件系统内)所能占用的空间量

RuntimeMaxFileSize=200M

重启日志

日志配置修改后需要重启

sudo systemctl restart systemd-journald


眼睛记得的光影,心记得的温度,它们不会消散,只是藏进岁月的褶皱里。某一天,风一吹,它们又鲜活如初...

Tim

infj 提倡者

站长

具有版权性

请您在转载、复制时注明本文 作者、链接及内容来源信息。 若涉及转载第三方内容,还需一同注明。

具有时效性

目录

欢迎来到Tim的博客,为您导航全站动态

45 文章数
4 分类数
3 评论数
48标签数

热门文章

D&F - Frida

2024-08-04

1716
D&F开服

2024-07-27

763
D&F - DP插件

2024-08-04

355

访问统计