鼎鼎知识库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

.NETCore在Ubuntu18.04下开机自启动.md 798B

  • 来到根目录:cd /
  • 创建文件:sudo touch /etc/systemd/system/znzm.service
  • 来到目录:/etc/systemd/system
  • 修改文件的权限:sudo chmod 666 znzm.service ``` [Unit] Description=znzm running on Ubuntu

[Service] WorkingDirectory=/var/www/znzm ExecStart=/usr/bin/dotnet /var/www/znzm/DD.Local.Web.dll Restart=always

Restart service after 10 seconds if the dotnet service crashes:

RestartSec=10 SyslogIdentifier=dotnet-example User=www-data Environment=ASPNETCORE_ENVIRONMENT=Production

[Install] WantedBy=multi-user.target ```

  • 修改文件的执行权限:sudo chmod +x znzm.service
  • 启用服务:sudo systemctl enable znzm.service
  • 启动服务:sudo systemctl start znzm.service
  • 查看服务:sudo systemclt status znzm.service
  • 重启服务器:sudo reboot