1.新建service文件
vim /etc/systemd/system/dotnetTest.service
内容
[Unit]Description=dotnet console[Service]WorkingDirectory=/home/useeinfo/publishExecStart=/usr/bin/dotnet /home/useeinfo/publish/ConsoleApp3.dllRestart=alwaysSyslogIdentifier=dotnet core consoleUser=rootEnvironment=ASPNETCORE_ENVIRONMENT=Production[Install]WantedBy=multi-user.target
2.开启服务
systemctl start dotnetTest.service
如果提示 systemctl: command not found,进行如下安装
apt-get install --reinstall systemd
也可以使用update-rc.d 命令管理系统服务
update-rc.d dotnetTest defaults 95 10
3.安装dotnet
wget -q https://packages.microsoft.com/config/ubuntu/14.04/packages-microsoft-prod.debdpkg -i packages-microsoft-prod.debapt-get install libunwind8-devapt-get install libicu-devapt-get install apt-transport-httpsapt-get updateapt-get install dotnet-sdk-2.1
手动测试
cd /home/ubuntu/mvcapp/publishdotnet Chloe.Admin.dll
3.其他操作
systemctl enable dotnetTest.servicesystemctl status dotnetTest.service