debian默认没有这个文件,并且服务是关闭的

创建/etc/rc.local,并写入内容

vim /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 restart rc.local

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

Logo

更多推荐