解决debian 9没有/etc/rc.local的方法

jsjcjsjc0条评论 49 次浏览

平时使用/etc/rc.local管理开机启动挺方便的,不过debian 9 默认没有启用/etc/rc.local,但是开启也很简单,直接复制下面的命令

cat <<EOF >/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
EOF

chmod +x /etc/rc.local
systemctl start rc-local

下面就可以直接使用/etc/rc.local了

sed -i '$i\这里替换成命令' /etc/rc.local
一个例子
sed -i '$i\/bin/bash /root/rtorrent.sh' /etc/rc.local


发表评论

? razz sad evil ! smile oops grin eek shock ??? cool lol mad twisted roll wink idea arrow neutral cry mrgreen