ubuntu18实现本地的 rc.local 功能,开机自动启动frpc
发布日期:2021-06-30 13:42:06 浏览次数:3 分类:技术文章

本文共 1079 字,大约阅读时间需要 3 分钟。

最近在实现frp的内网穿透,但是一直开机不能自动启动,这样的设计肯定是不行的,现在将我找到的开机自动启动的方法分享一下。

本博客参考于

ubuntu18 貌似是已经不支持rc.local 这个开机自动启动的脚本了,所以为了能继续用这个脚本,我需要去编写一个ubuntu18 下的启动脚本,通过这个脚本来启动我的rc.local脚本。

创建一个rc-local.service

sudo vi /etc/systemd/system/rc-local.service
[Unit]Description=/etc/rc.local CompatibilityConditionPathExists=/etc/rc.local [Service]Type=forkingExecStart=/etc/rc.local startTimeoutSec=0StandardOutput=ttyRemainAfterExit=yesSysVStartPriority=99 [Install]WantedBy=multi-user.target

将上面这段内容写到rc-local.service。

接下来就是创建一个rc.local

sudo vi /etc/rc.local
#!/bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.nohup /home/jeason/frp/frpc -c /home/jeason/frp/frpc.ini & # 启动frpexit 0

将上述的脚本赋值到rc.local   注意 关于frpc 的运行指令必须包含完整的路径!

接下来是给rc.local 执行的权限

sudo chmod +x /etc/rc.local

接下来是启动服务

sudo systemctl start rc-local.service

测试服务的状态

sudo systemctl status rc-local.service

 

转载地址:https://jeason.blog.csdn.net/article/details/107892325 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:rapidjson笔记--rapidjson读取/修改/保存以及输出pretty的结构 windows 下使用cmake做json 解析 rapidjson
下一篇:嵌入式linux 学习-- linux服务器搭建smb 共享实现windows下编程linux 下编译

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月11日 01时59分45秒