CentOS系统下设置开机自动启动
方法1. 把启动程序的命令添加到 /etc/rc.d/rc.local 文件中,比如设置开机启动 mysqld:
#!/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/init.d/mysqld start #就是添加这一条语句
方法3. 把启动程序的命令添加到 /etc/rc.d/rc.sysinit 文件中
脚本 /etc/rc.d/rc.sysinit 的作用是完成系统服务程序的启动,如环境变量设置、设置系统时钟、加载字体、检查加载文件系统、生成系统启动信息日志文件等。
比如我们设置自启动 mysqld:
echo "/etc/init.d/mysqld start" >> /etc/rc.d/rc.sysinit