Linux 創建屬於自己的程序服務

@zgcwkj  2023年12月30日

分類:

代碼 其它 

創建並配置屬於自己的 Linux 程序服務

cd /etc/systemd/system

vim test.service
內容
[Unit]
Description=TestService

[Service]
WorkingDirectory=/var/www/TestService
ExecStart=/usr/bin/dotnet /var/www/TestService/TestService.dll
SyslogIdentifier=TestService
Environment=Production
ASPNETCORE_ENVIRONMENT=Production
User=root
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
服務命令
啟動
systemctl start test.service

停止
systemctl stop test.service

重啟
systemctl restart test.service

重載配置
systemctl reload test.service

開啟自啟
systemctl enable test.service

關閉自啟
systemctl disable test.service


評論已關閉

Top