1,新建service文件
vim /etc/systemd/system/dotnetTest.service
内容
[Unit]
Description=dotnet console
[Service]
WorkingDirectory=/home/useeinfo/publish
ExecStart=/usr/bin/dotnet /home/useeinfo/publish/ConsoleApp3.dll
Restart=always
SyslogIdentifier=dotnet core console
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
2,开启服务
systemctl start dotnetTest.service
查看状态
systemctl status dotnetTest.service
Loaded: loaded (/etc/systemd/system/dotnetTest.service; disabled; vendor pres
Active: active (running) since Mon 2019-03-04 14:10:55 CST; 20s ago
Main PID: 6893 (dotnet)
Tasks: 10 (limit: 4915)
Memory: 27.1M
CGroup: /system.slice/dotnetTest.service
└─6893 /usr/bin/dotnet /home/wht/DotNetCore/test/ConsoleApp1.dll
停止服务
systemctl stop dotnetTest.service