中午好!午休时间哦,朋友一定是不习惯午睡的吧?!

Debian设置脚本开机自启

   

记录一下在Debian系统下自己测试有效的开机自启脚本设置方法。

1、新建脚本(我这里以Frp服务端运行脚本为例)

脚本代码很简单:

#!/bin/sh
/root/frps/frps -c /root/frps/frps.ini

2、给脚本添加执行权限

chmod +x /root/frps/frps.sh

3、在/etc目录下找到rc.local文件(没有则新建一个),在exit 0的前面添加如下代码:

nohup /root/frps/frps.sh &

nohup代表不挂断运行; & 代表后台运行。
完整的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 /root/frps/frps.sh &
exit 0

4、最后reboot重启服务器即可

未经允许不得转载:Rising Sun's Blog » Linux » Debian设置脚本开机自启
标签:
评论 0
 
 
发表评论