Running Additional Programs at Boot Time (开机启动)
https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-boot-init-shutdown-run-boot.html
The /etc/rc.d/rc.local script is executed by the init command at boot time or when changing runlevels. Adding commands to the bottom of this script is an easy way to perform necessary tasks like starting special services or initialize devices without writing complex initialization scripts in the /etc/rc.d/init.d/ directory and creating symbolic links.
The /etc/rc.serial script is used if serial ports must be setup at boot time. This script runs setserialcommands to configure the system's serial ports. Refer to the setserial man page for more information.
[root@iZ255m2u8usZ rc.d]# cat rc.local #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local
注:
/etc/rc.d/rc.local 和 /etc/rc.local 指向的是同一个文件
/etc/profile 中配置的环境变量在这里不起作用
举例:
[root@iZ255m2u8usZ ~]# cat /etc/rc.local #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local export JAVA_HOME=/usr/local/jdk1.7.0_79 /usr/local/apache-tomcat-7.0.70/bin/startup.sh
可能出问题的点:脚本问题(环境变量)、执行权限。
检查启动日志:
/var/log/boot.log