LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1057|回复: 3

帮我看下这个脚本rc.local的含义

[复制链接]
发表于 2007-7-19 23:44:59 | 显示全部楼层 |阅读模式
vim /etc/init.d/rc.local

#! /bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin
[ -f /etc/default/rcS ] && . /etc/default/rcS
. /lib/lsb/init-functions

do_start() {
        if [ -x /etc/rc.local ]; then
                log_begin_msg "Running local boot scripts (/etc/rc.local)"
                /etc/rc.local
                log_end_msg $?
        fi
}

case "$1" in
    start)
        do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

(该文件结束啦~)

ls -l /etc/rc.local
-rwxr-xr-x 1 root root 385 2007-07-18 21:10 /etc/rc.local

问题是:我在/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.
sudo /sbin/ifconfig eth1 hw ether 00:00:E0:80:30:9A
sudo /sbin/ifconfig eth1 up
exit 0
发表于 2007-7-20 09:45:33 | 显示全部楼层
你的/etc/rc.local有x属性么
回复 支持 反对

使用道具 举报

发表于 2007-7-20 10:56:12 | 显示全部楼层
rc.local这个没有使用start参数,你试试只是写一些脚本在里面,不要有什么start,stop之类的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-7-20 18:24:38 | 显示全部楼层
有执行属性啊!

请看中间部分的ls -l输出结果。

这个……
/etc/init.d/rc.local 不是我写的啊,是Kubuntu自带的,里面start stop参数部分也是它写的。
而/etc/rc.local也是它自带,我只是按照它注释部分添加了自己的两条ifconfig语句。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表