首页 > 技术分享 > Debian
收藏

Debian通过rc-local配置软件开机自启,Debian没有rc.local解决办法

05/19 15:00
大潇博客 原创文章,转载请标明出处

Debian设置某些软件开机启动,一般是将命令添加到/etc/rc.local,通过rc-local服务设置开机启动


Debian自带rc-local服务,默认不启动,且默认不带rc.local文件,所以需要创建rc.local文件,然后启动rc-local服务


创建/etc/rc.local

nano /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.


exit 0


赋予执行权限

chmod a+x /etc/rc.local


启动rc.local

systemctl start rc-local   


将要开机执行的命令添加到/etc/rc.local中exit 0的上面即可


比如服务器中安装了迅搜,进程启动文件是:/www/xunsearch/bin/xs-ctl.sh,那么/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.


/www/xunsearch/bin/xs-ctl.sh start

exit 0


打赏

阅读排行

大家都在搜

博客维护不易,感谢你的肯定
扫码打赏,建议金额1-10元
  • 15601023311