centos设置开机自启动
生活随笔
收集整理的這篇文章主要介紹了
centos设置开机自启动
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在CentOS系統(tǒng)下,主要有兩種方法設(shè)置自己安裝的程序開(kāi)機(jī)啟動(dòng)。
1、把啟動(dòng)程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是設(shè)置開(kāi)機(jī)啟動(dòng)httpd。
復(fù)制代碼#!/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
/usr/local/apache/bin/apachectl start復(fù)制代碼2、把寫好的啟動(dòng)腳本添加到目錄/etc/rc.d/init.d/,然后使用命令chkconfig設(shè)置開(kāi)機(jī)啟動(dòng)。chkconfig 功能說(shuō)明:檢查,設(shè)置系統(tǒng)的各種服務(wù)。語(yǔ)法:chkconfig [--add][--del][--list][系統(tǒng)服務(wù)] 或 chkconfig [--level <等級(jí)代號(hào)>][系統(tǒng)服務(wù)][on/off/reset]--add 添加服務(wù)--del 刪除服務(wù)--list 查看各服務(wù)啟動(dòng)狀態(tài)比如我們?cè)O(shè)置自啟動(dòng)mysql:
復(fù)制代碼1 #將mysql啟動(dòng)腳本放入所有腳本運(yùn)行目錄/etc/rc.d/init.d中2 cp /lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld3 4 #改變權(quán)限5 chown root.root /etc/rc.d/init.d/mysqld6 7 #所有用戶都可以執(zhí)行,單只有root可以修改8 chmod 755 /etc/rc.d/init.d/mysqld9
10 #將mysqld 放入linux啟動(dòng)管理體系中
11 chkconfig --add mysqld
12
13 #查看全部服務(wù)在各運(yùn)行級(jí)狀態(tài)
14 chkconfig --list mysqld
15
16 #只要運(yùn)行級(jí)別3啟動(dòng),其他都關(guān)閉
17 chkconfig --levels 245 mysqld off復(fù)制代碼例如:我們把httpd的腳本寫好后放進(jìn)/etc/rc.d/init.d/目錄,使用chkconfig --add httpd
chkconfig httpd on命令即設(shè)置好了開(kāi)機(jī)啟動(dòng)。3、把啟動(dòng)程序的命令添加到/etc/rc.d/rc.sysinit 文件中腳本/etc/rc.d/rc.sysinit,完成系統(tǒng)服務(wù)程序啟動(dòng),如系統(tǒng)環(huán)境變量設(shè)置、設(shè)置系統(tǒng)時(shí)鐘、加載字體、檢查加載文件系統(tǒng)、生成系統(tǒng)啟動(dòng)信息日志文件等比如我們?cè)O(shè)置自啟動(dòng)apache:echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit
?
注:轉(zhuǎn)自http://www.cnblogs.com/xlmeng1988/archive/2013/05/22/3092447.html
轉(zhuǎn)載于:https://www.cnblogs.com/thingk/p/4334604.html
總結(jié)
以上是生活随笔為你收集整理的centos设置开机自启动的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 学习卫星菜单
- 下一篇: BZOJ 1606: [Usaco200