1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - debian - 正文

君子好学,自强不息!

Debian如何创建后端运行服务程序?

2022-08-27 | debian | 1818ip | 950°c
A+ A-

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



本文来源:1818IP

本文地址:https://www.1818ip.com/post/3146.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。