首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >CentOS6设置开机自启动

CentOS6设置开机自启动

原创
作者头像
陈不成i
修改于 2021-05-26 14:22:48
修改于 2021-05-26 14:22:48
4.1K0
举报
文章被收录于专栏:ops技术分享ops技术分享

1.把开机启动脚本(mysqld)copy到文件夹/etc/init.d 或 /etc/rc.d/init.d 中

2.将启动程序的命令添加到 /etc/rc.d/rc.local 文件中,比如:

  1. #!/bin/sh
  2. #
  3. # This script will be executed *after* all the other init scripts.
  4. # You can put your own initialization stuff in here if you don't
  5. # want to do the full Sys V style init stuff.
  6. touch /var/lock/subsys/local
  7. /etc/init.d/mysqld start #就是添加这一条语句

注: /etc/init.d 是 /etc/rc.d/init.d 的软链接 /etc/rc.local 是 /etc/rc.d/rc.local 的软链接

3.另一种方法

使用命令chkconfig设置开机启动

  1. chkconfig功能说明:检查,设置系统的各种服务
  2. 语法:
  3. chkconfig [--add][--del][--list][系统服务] 或
  4. chkconfig [--level<等级代号>][系统服务][on/off/reset]
  5. --add 添加服务
  6. --del 删除服务
  7. --list 查看各服务启动状态

比如设置自启动mysql:

  1. #将mysql启动脚本放入所有脚本运行目录/etc/rc.d/init.d中
  2. cp /lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld
  3. #改变权限
  4. chown root.root /etc/rc.d/init.d/mysqld
  5. #所有用户都可以执行,单只有root可以修改
  6. chmod 755 /etc/rc.d/init.d/mysqld
  7. #将mysqld 放入linux启动管理体系中
  8. chkconfig --add mysqld
  9. #查看全部服务在各运行级状态
  10. chkconfig --list mysqld
  11. #只要运行级别3启动,其他都关闭
  12. chkconfig --levels 245 mysqld off

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档