【OpsDEV】关于Debian7系统启动时没有执行/etc/rc.local文件
2016-08-19 15:58
483 查看
最近调试的debian7系统突然出了些异常, rc.local貌似不会在启动时执行了, 很多开机任务没有正常启动, 因此不得不在这个问题上来折腾一番。
首先查了下当前的运行级别:
。。。。。。
我以为是哪里的服务卡住了, 但貌似又没有。后来是不经意间在/etc/init.d/rc.local中将
reboot后居然可以正常运行了。 抱歉自己学疏才浅, 暂时不太明白其中的道理, 既然有执行权限怎么还需要加/bin/bash ?也不明白最初的时候为啥可以正常执行。
暂且这样吧。
首先查了下当前的运行级别:
xiaomo:/home/xiaomo# runlevel N 5然后去到对应的/etc/rc5.d/目录查看:
xiaomo:/home/xiaomo# ls /etc/rc5.d/ -al 总用量 20 drwxr-xr-x 2 root root 4096 7月 18 14:58 . drwxr-xr-x 138 root root 12288 8月 19 15:18 .. -rw-r--r-- 1 root root 677 4月 7 2015 README lrwxrwxrwx 1 root root 19 7月 18 14:58 S01minissdpd -> ../init.d/minissdpd lrwxrwxrwx 1 root root 14 7月 18 13:45 S01motd -> ../init.d/motd lrwxrwxrwx 1 root root 17 7月 18 13:46 S01rsyslog -> ../init.d/rsyslog lrwxrwxrwx 1 root root 15 7月 18 13:46 S02acpid -> ../init.d/acpid lrwxrwxrwx 1 root root 17 7月 18 14:57 S02anacron -> ../init.d/anacron lrwxrwxrwx 1 root root 13 7月 18 14:57 S02atd -> ../init.d/atd lrwxrwxrwx 1 root root 14 7月 18 13:46 S02cron -> ../init.d/cron lrwxrwxrwx 1 root root 14 7月 18 14:57 S02dbus -> ../init.d/dbus lrwxrwxrwx 1 root root 15 7月 18 14:57 S02exim4 -> ../init.d/exim4 lrwxrwxrwx 1 root root 16 7月 18 14:57 S02gdomap -> ../init.d/gdomap lrwxrwxrwx 1 root root 27 7月 18 14:58 S02speech-dispatcher -> ../init.d/speech-dispatcher lrwxrwxrwx 1 root root 13 7月 18 14:58 S02ssh -> ../init.d/ssh lrwxrwxrwx 1 root root 22 7月 18 14:57 S03avahi-daemon -> ../init.d/avahi-daemon lrwxrwxrwx 1 root root 19 7月 18 14:57 S03bluetooth -> ../init.d/bluetooth lrwxrwxrwx 1 root root 25 7月 18 14:58 S03network-manager -> ../init.d/network-manager lrwxrwxrwx 1 root root 14 7月 18 14:57 S04cups -> ../init.d/cups lrwxrwxrwx 1 root root 22 7月 18 14:57 S04cups-browsed -> ../init.d/cups-browsed lrwxrwxrwx 1 root root 14 7月 18 14:58 S04gdm3 -> ../init.d/gdm3 lrwxrwxrwx 1 root root 15 7月 18 14:58 S04saned -> ../init.d/saned lrwxrwxrwx 1 root root 18 7月 18 14:58 S05bootlogs -> ../init.d/bootlogs lrwxrwxrwx 1 root root 18 7月 18 14:58 S06rc.local -> ../init.d/rc.local lrwxrwxrwx 1 root root 19 7月 18 14:58 S06rmnologin -> ../init.d/rmnologin然后找到/etc/init.d/rc.local:
xiaomo:/home/xiaomo# cat /etc/init.d/rc.local #! /bin/sh ### BEGIN INIT INFO # Provides: rc.local # Required-Start: $all # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: Run /etc/rc.local if it exist ### END INIT INFO PATH=/sbin:/usr/sbin:/bin:/usr/bin . /lib/init/vars.sh . /lib/lsb/init-functions do_start() { if [ -x /etc/rc.local ]; then [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" /etc/rc.local ES=$? [ "$VERBOSE" != no ] && log_end_msg $ES return $ES fi } case "$1" in start) do_start ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop|status) # No-op exit 0 ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac该文件会先判断/etc/rc.local的权限再运行它, 看起来没有问题; 然后又看了一下/etc/rc.local的执行权限:
xiaomo:/home/xiaomo# ls -lh /etc/rc.local -rwxr-xr-x 1 root root 306 7月 18 13:45 /etc/rc.local看起来也是没有问题, 这就纳闷了, 一脸懵逼。
。。。。。。
我以为是哪里的服务卡住了, 但貌似又没有。后来是不经意间在/etc/init.d/rc.local中将
if [ -x /etc/rc.local ]; then [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" /etc/rc.local ES=$? [ "$VERBOSE" != no ] && log_end_msg $ES return $ES fi改成了
if [ -x /etc/rc.local ]; then [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" /bin/bash /etc/rc.local ES=$? [ "$VERBOSE" != no ] && log_end_msg $ES return $ES fi
reboot后居然可以正常运行了。 抱歉自己学疏才浅, 暂时不太明白其中的道理, 既然有执行权限怎么还需要加/bin/bash ?也不明白最初的时候为啥可以正常执行。
暂且这样吧。
相关文章推荐
- Debian下系统启动时执行脚本
- 关于运行VBS文件提示“没有在该机执行windows脚本宿主的权限。请与系统管理员联系。”错误的解决方法
- 关于 AIX 特定 文件 系统 下 , 没有权限 执行 (已解决)
- FIS--关于下载php后的配置(启动fis的调试服务器(注意添加 --no-rewrite 参数),如果报错 没有php-cgi环境,请 安装 它,并把php-cgi命令加到系统的环境变量)
- 关于系统检测到您机器上没有启动QQ的解决方法
- fedora学习笔记 5:关于用grub命令启动系统的补充
- 关于Linux操作系统根文件系统的启动分析
- 关于ubuntu系统启动时显示.dmrc权限不正确的问题的解决
- Ubuntu/Debian与REDHAT系统启动脚本之对照
- 关于管理系统或水晶报表显示小数是没有起零的问题
- 关于双系统启动问题
- linux操作之:设置系统启动时,自动启动一些程序,或者执行一些命令
- Debian系统启动脚本详解-update-rc.d
- 关于linux系统一启动就调用某个程序
- 关于系统启动慢的解决
- 关于Linux操作系统根文件系统的启动分析
- 系统启动没有声音,音量控制图标不能正常显示,但realplayer能正常播放
- Debian系统启动脚本
- 关于——IIS服务没有及时响应启动或控制请求 的解决
- 解决MOSS2007启动单一登录服务时出现“您没有执行此操作的权限”