在Linux CentOS7下设置netcore Net5 项目开机自启

在Linux CentOS7下设置netcore Net5 项目开机自启

一、创建文件

在etc/systemd/system下创建xxx.service文件

例如:
vi /etc/systemd/system/ubif.service

 

二、编辑文件

内容如下:

[Unit]
Description="ubif Service"      

[Service]
Type=simple
GuessMainPID=true
WorkingDirectory=/var/ubif/UbifPublish/                                            //项目路径
StandardOutput=journal
StandardError=journal
ExecStart=/usr/bin/dotnet UBIF.Web.dll                                           //启动指令
Restart=always

[Install]
WantedBy=multi-user.target

三、添加到自启

cd /etc/systemd/system/

systemctl enable ubif.service

四、启动服务

systemctl start ubif.service

五、服务状态

systemctl status ubif.service  //查看服务
systemctl start ubif.service //启动服务
systemctl restart ubif.service //重启服务
systemctl stop ubif.service //停止服务

 

posted @ 2021-03-08 16:19  积山海  阅读(484)  评论(0编辑  收藏  举报