.netcore centos配置systemctl自动启动

systemd分两种服务系统和用户服务

对应存储位路径为系统(/usr/lib/systemd/system)、用户(/etc/systemd/user/)

[Unit]    
Description=api services    
After=network.target         
[Service]    
Type=forking    
ExecStart=/Service/API/RunDotNetServices.sh    
ExecReload=/Service/API/RunDotNetServices.sh     
ExecStop=/Service/API/RunDotNetServices.sh    
PrivateTmp=true    
[Install]    
WantedBy=multi-user.target  

启动服务

systemctl start file.service

这里的fileservice为文件名

将会调用配置中的脚本

ExecStart:启动脚本

ExecReload:重启脚本

ExecStop:停止脚本

开机自启配置

systemctl enable file.service

原文地址:https://www.cnblogs.com/ives/p/systemctl.html