使用systemd增加linux 开机启动项
系统版本为 Ubuntu 20.04.3 LTS
创建service文件
在/etc/systemd/system 下创建一个 frp-core.service 文件
内容为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | [Unit] #当前服务的简单描述 Description=Frp Core [Service] # 要执行的bash文件 ExecStart=/home/ubuntu/frp/frp_core/start.sh # 后台执行 Type=oneshot # 设为yes,表示进程退出以后,服务仍然保持执行 RemainAfterExit=yes [Install] WantedBy=multi-user.target |
/home/ubuntu/frp/frp_core/start.sh:
1 2 3 4 | #!/bin/sh # 一定要有上边那行 否则启动服务会报 203 echo '开机自启动' |
重新加载服务
添加或修改配置文件后,需要重新加载
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # 添加或修改配置文件后,需要重新加载 systemctl daemon-reload # 开机启动 systemctl enable frp-core # 关闭开机启动 systemctl disable frp-core # 启动服务 systemctl start frp-core # 停止服务 systemctl stop frp-core # 重启服务 systemctl restart frp-core # 查看服务状态 systemctl status frp-core # 结束服务进程(服务无法停止时) systemctl kill frp-core |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # taishi enterprise supervisord service for systemd (CentOS 7.0+) [Unit] Description=taishi Enterprise Supervisor daemon After=taishi.service [Service] Type=forking LimitNOFILE=655350 LimitNPROC=655350 ExecStart=/bin/bash /app/taishi/etc/start_taishi.sh ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown ExecReload=/usr/bin/supervisorctl $OPTIONS reload KillMode=process Restart=no TimeoutSec=1200s [Install] WantedBy=multi-user.target |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | [Unit] #当前服务的简单描述 Description=Frp Core [Service] # 要执行的bash文件 ExecStart=/bin/bash /app/taishi/app/main/ static /script/IP_update.sh # 后台执行 Type=oneshot # 设为yes,表示进程退出以后,服务仍然保持执行 RemainAfterExit=yes [Install] WantedBy=multi-user.target |
__EOF__

本文作者:有点丿东西
本文链接:https://www.cnblogs.com/Jeffrey1172417122/p/16892661.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
本文链接:https://www.cnblogs.com/Jeffrey1172417122/p/16892661.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 我与微信审核的“相爱相杀”看个人小程序副业
· DeepSeek “源神”启动!「GitHub 热点速览」
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库