obsidian/笔记文件/2.笔记/Ubuntu linux开机自启.md
2025-03-26 00:02:56 +08:00

1.1 KiB
Raw Permalink Blame History

#杂七杂八常识

先确认,是进入管理员模式;

!Pasted image 20240924221210.png

以自启frp内网穿透为例 打开命令行工具nano新建一个文本

nano seafile.sh

输入自启脚本,参考

以#!/bin/bash开头 中间写脚本内容 exit 0 结尾 注释信息不可少,不然不生效

#!/bin/bash

### BEGIN INIT INFO
# Provides:     test
# Required-Start:  $remote_fs $syslog
# Required-Stop:   $remote_fs $syslog
# Default-Start:   2 3 4 5
# Default-Stop:   0 1 6
# Short-Description: start test
# Description:    start test
### END INIT INFO

#此处编写脚本内容
cd /root/frp_0.27.0_linux_amd64/
nohup ./frps -c ./frps.ini
exit 0

!Pasted image 20240924221013.png

保存修改chmod设置权限

chmod 755 seafile.sh

移动脚本,到自启文件夹 /etc/init.d/

mv test.sh /etc/init.d/

将脚本添加到,启动脚本中

update-rc.d seafile.sh defaults

如果需要移除,该自启脚本; 跳转到该目录然后remove相关指令即可

cd /etc/init.d
**update-rc.d -f seafile.sh remove**