在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
/etc/inittab文件描述了哪些进程开始启动并正常运行。inittab为linux初始化文件系统时init初始化程序用到的配置文件。这个文件负责设置init初始化程序初始化脚本在哪里;每个运行级初始化时运行的命令; 开机、关机、重启对应的命令;各运行级登陆时所运行的命令。 inittab文件中的条目的格式如下: label:runlevels:action:process 下面分别介绍各个字段 1.label 常用标签有: id 用来定义缺省的init运行的级别 2.runlevels runlevel 0是让init关闭所有进程并终止系统。 debian6以后默认没有运行/etc/inittab 文件 默认级别为2-5归为一类
respawn 不管何时终止都重新启动进程
复制代码 代码如下:# /etc/inittab: init(8) configuration. # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ 复制代码 代码如下:# The default runlevel. id:2:initdefault: #表示当前缺省运行级别为2 复制代码 代码如下:# Boot-time system configuration/initialization script. # This is run first except when booting in emergency (-b) mode. si::sysinit:/etc/init.d/rcS #系统初始化的进程 复制代码 代码如下:# What to do in single-user mode. ~~:S:wait:/sbin/sulogin 复制代码 代码如下:# /etc/init.d executes the S and K scripts upon change # of runlevel. # # Runlevel 0 is halt. # Runlevel 1 is single-user. # Runlevels 2-5 are multi-user. # Runlevel 6 is reboot. 复制代码 代码如下:l0:0:wait:/etc/init.d/rc 0 l1:1:wait:/etc/init.d/rc 1 l2:2:wait:/etc/init.d/rc 2 l3:3:wait:/etc/init.d/rc 3 l4:4:wait:/etc/init.d/rc 4 l5:5:wait:/etc/init.d/rc 5 l6:6:wait:/etc/init.d/rc 6 # Normally not reached, but fallthrough in case of emergency. z6:6:respawn:/sbin/sulogin 复制代码 代码如下:# What to do when CTRL-ALT-DEL is pressed. #在启动过程中是否允许按CTRL-ALT-DELETE重启系统 #ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now 复制代码 代码如下:# Action on special keypress (ALT-UpArrow). #kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." 复制代码 代码如下:# What to do when the power fails/returns. pf::powerwait:/etc/init.d/powerfail start pn::powerfailnow:/etc/init.d/powerfail now po::powerokwait:/etc/init.d/powerfail stop 复制代码 代码如下:# /sbin/getty invocations for the runlevels. # # The "id" field MUST be the same as the last # characters of the device (after "tty"). # # Format: # <id>:<runlevels>:<action>:<process> # # Note that on most Debian systems tty7 is used by the X Window System, # so if you want to add more getty's go ahead but skip tty7 if you run X. # getty进程来提供虚拟终端设备的服务 1:2345:respawn:/sbin/getty 38400 tty1 复制代码 代码如下:#标签字段的值是1,1是设备tty1的数字后缀,tty1与相应的进程相关联,该getty进程可以启动的runlevel是2,3,4和5,当该进程终止时,init马上就重新启动它。启动进程的路径名是/sbin/getty,该进程是实现虚拟终端支持的最小版本的getty,为tty1提供启动虚拟设备的进程。 2:23:respawn:/sbin/getty 38400 tty2 #3:23:respawn:/sbin/getty 38400 tty3 #4:23:respawn:/sbin/getty 38400 tty4 #5:23:respawn:/sbin/getty 38400 tty5 #6:23:respawn:/sbin/getty 38400 tty6 # Example how to put a getty on a serial line (for a terminal) # #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 T1:23:respawn:/sbin/getty -L ttyS1 115200 vt100 # Example how to put a getty on a modem line. # #T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 5.示例 复制代码 代码如下:# Begin /etc/inittab id:3:initdefault: si::sysinit:/etc/rc.d/init.d/rc sysinit l0:0:wait:/etc/rc.d/init.d/rc 0 l1:S1:wait:/etc/rc.d/init.d/rc 1 l2:2:wait:/etc/rc.d/init.d/rc 2 l3:3:wait:/etc/rc.d/init.d/rc 3 l4:4:wait:/etc/rc.d/init.d/rc 4 l5:5:wait:/etc/rc.d/init.d/rc 5 l6:6:wait:/etc/rc.d/init.d/rc 6 ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now su:S016:once:/sbin/sulogin 1:2345:respawn:/sbin/agetty tty1 9600 2:2345:respawn:/sbin/agetty tty2 9600 3:2345:respawn:/sbin/agetty tty3 9600 4:2345:respawn:/sbin/agetty tty4 9600 5:2345:respawn:/sbin/agetty tty5 9600 6:2345:respawn:/sbin/agetty tty6 9600 # End /etc/inittab |
请发表评论