鼎鼎知识库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

.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