Debian Linux创建后端运行服务程序
1、在/etc/systemd/system/目录创建服务.service文件,例如:service1.service
[Unit] Description=ServiceName(服务名称) After=network.target [Service] Type=notify User=root WorkingDirectory=/usr/local/servicePath(工作目录) ExecStart=/usr/local/servicePath/service1(程序路径) Restart=always RestartSec=10 KillSignal=SIGINT [Install] WantedBy=multi-user.target
2、设置服务运行目录权限
chmod 755 /usr/local/servicePath(服务程序工作目录)
3、服务管理及启用开机自动运行
#状态
systemctl status service1
#运行
systemctl start service1
#停止
systemctl stop service1
#重启
systemctl restart service1
#开机自动运行
systemctl enable service1
相关文章
标签:linux