
方法一:
1.1 步骤一
编辑/etc/init.d/rc脚本,在最后一个exit 0之前,加入以下内容:
rc_local=/etc/rc.d/rc.local
current_runlevel=$(runlevel | awk "{ print $NF }")
if [ -x $rc_local ];then
((current_runlevel>1)) && ((current_runlevel<6)) && {
echo -e "
"
echo "-----------------------Startup $rc_local---------------------------"
$rc_local
}
fi
以上为脚本内容
1.2 步骤二
然后创建/etc/rc.local文件,并赋予755权限:
chmod 0755 /etc/rc.d/rc.local
方法二:
2.1 步骤一
创建/etc/rc.d/rclocal文件,加入以下内容:
case "$1" in
start)
if ! test -x /etc/init.d/rc.local ; then
echo "/etc/rc.local is not exsit!"
exit 1
fi
/etc/init.d/rc.local &
;;
stop)
;;
esac
以上为脚本内容
2.2 步骤二
创建/etc/rc.d/rc.local,把你要开机执行的脚本都加到里面
2.3 步骤三
chmod 0755 /etc/rc.d/rc.local /etc/rc.d/rclocal
2.4 步骤四
chkconfig --add rclocal
以上就是小编罗列出来的使用rc.local的两种方法。如果友友们还有其他的使用方法,也可以与小编留言交流互动哦。