LinuxSir.cn,穿越时空的Linuxsir!

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

在suse中使用rc.local的方法

[复制链接]
发表于 2007-7-31 17:00:23 | 显示全部楼层 |阅读模式
问的人太多了,而且很多人对boot.local不太满意。测试了一下,发现是可以像其他发行使用rc.local的,不过得改一下系统的脚本。

编辑/etc/init.d/rc脚本,在最后一个exit 0之前,加入以下内容,然后创建/etc/rc.local文件,并赋予755权限。
  1. rc_local=/etc/rc.local
  2. current_runlevel=$(runlevel | awk '{ print $NF }')
  3. if [ -x $rc_local ];then
  4.    ((current_runlevel>1)) && ((current_runlevel<6)) && {
  5.      echo -e "\n\n\n"
  6.      echo "-----------------------Startup $rc_local---------------------------"
  7.      $rc_local
  8.    }
  9. fi
复制代码
发表于 2007-7-31 18:07:23 | 显示全部楼层
前辈回来了。 :)
回复 支持 反对

使用道具 举报

发表于 2007-7-31 23:15:36 | 显示全部楼层
/etc/init.d/boot.local不是和你的rc.local一样用吗???
回复 支持 反对

使用道具 举报

发表于 2007-8-1 00:52:42 | 显示全部楼层
Post by Netwrom
/etc/init.d/boot.local不是和你的rc.local一样用吗???


不一樣。
boot.local 是在 RC scripts 之前就跑了。
如果 RC scripts 裡面有重設,或必需等 RC scripts 跑完才能設的話,
那 boot.local 就沒效了。
R/H 的 rc.local 是在 Sxxxxx 那堆 script 裡面跑在最後的,一般是 S99 。
SuSE 沒有 rc.local,所以要自己改。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-1 12:13:34 | 显示全部楼层
倒……仔细看了一下/etc/init.d/rc脚本。

发现SUSE是可以这么定义自己的脚本的,如果希望在切换运行级之前和之后运行自己的脚本,那么可以分别创建:
/etc/init.d/before.local
/etc/init.d/after.local

不用自己改rc了。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-8-1 12:24:28 | 显示全部楼层
Post by linux_pro
前辈回来了。 :)


-_-!

不要叫我前辈,我没那么老,也不牛,只是用多SUSE多些而已。
回复 支持 反对

使用道具 举报

发表于 2007-8-1 13:17:27 | 显示全部楼层
Post by kde2000
倒……仔细看了一下/etc/init.d/rc脚本。

发现SUSE是可以这么定义自己的脚本的,如果希望在切换运行级之前和之后运行自己的脚本,那么可以分别创建:
/etc/init.d/before.local
/etc/init.d/after.local

不用自己改rc了。

原来是这样的……明白了
回复 支持 反对

使用道具 举报

发表于 2007-8-3 01:11:52 | 显示全部楼层
Hi!

Some people expect the system startup scripts in /etc/rc.d/.
We use a slightly different structure for better LSB compliance.
You can find the equivalent files in /etc/init.d/.
The behaviour of the scripts can be configured in the files
below the directory /etc/sysconfig/.

For detailed information please have a look into the SuSE Linux manual.
If you don't have a printed manual, you can find the electronic version
in /docu on the first CDROM or in the package 'books.rpm'.

You may also want to read /etc/init.d/README for more information.

Have a lot of fun

                     Your SuSE Team
回复 支持 反对

使用道具 举报

发表于 2007-8-3 13:54:35 | 显示全部楼层
还有boot.local和halt.local,都是放自己的脚本的地方,这两个脚本系统中已经有了,before.local和after.local需要自己建了。并且是每次切换运行极别的时候都会调用。
回复 支持 反对

使用道具 举报

发表于 2008-11-6 23:01:59 | 显示全部楼层
before.local和after.local是好东东啊
回复 支持 反对

使用道具 举报

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

本版积分规则

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