當前位置:首頁 » 操作系統 » 開機自啟動linux

開機自啟動linux

發布時間: 2022-08-02 08:58:16

linux:怎麼設置服務開機自動啟動

linux設置開機服務自動啟動/關閉自動啟動命令
[root@localhost
~]#
chkconfig
--list
顯示開機可以自動啟動的服務
[root@localhost
~]#
chkconfig
--add
***
添加開機自動啟動***服務
[root@localhost
~]#
chkconfig
--del
***
刪除開機自動啟動...

② 怎樣將一個linux服務設置成開機啟動

linux設置開機服務自動啟動

[root@localhost ~]# chkconfig --list 顯示開機可以自動啟動的服務

[root@localhost ~]# chkconfig --add *** 添加開機自動啟動***服務

[root@localhost ~]# chkconfig --del *** 刪除開機自動啟動***服務

www.2cto.com

[root@localhost ~]# setup 可以在shell圖形終端裡面配置的命令,去service里選擇

[root@localhost ~]# ntsysv 在shell終端圖形配置開機啟動服務命令,選項沒上面那個多

setup 、rc.local 和chkconfig三種方式都可以設置

第一種)

輸入#setup指令進入系統服務菜單,選擇你想啟動的服務比如httpd,然後重起機器或者/etc/rc.d./init.d/httpd

start

www.2cto.com

第二種)

把啟動命令放到/etc/rc.d/rc.local文件里這樣就可以每次啟動的時候自動啟動服務了,例如對於apache,編譯好apache後會在安裝目錄的bin下生成apachectl文件,這是個啟動腳本,我們只需要把這個命令加到rc.local里就可以了

(suse沒有rc.local。SUSE是可以這么定義自己的腳本的,如果希望在切換運行級之前和之後運行自己的腳本,那麼可以分別創建:

/etc/init.d/before.local

/etc/init.d/after.local)

echo /usr/local/apache/bin/apachectl>> /etc/rc.d/rc.local,

設置服務自動啟動的方式是在rc.local里還可以加入類似以下的一些腳本:

#sshd

/usr/local/sbin/sshd

#proftpd

/usr/local/sbin/proftpd

#apache

/home/apache/bin/apachectl start

#mysql

/home/mysql/bin/safe_mysqld --port=3306 &

#start oracle8i listener first

su - oracle -c 'lsnrctl start'

#start oracle8i

su - oracle -c 'dbstart'

第三種)

通過chkconfig指令.

使用chkconfig命令來把某項服務加到系統的各項運行級別中,步驟如下,

1 創建啟動腳本.

對於apache,mysql,ssh這樣的軟體都是自己帶的,我們只要稍微修改一下使之支持chkconfig就可以了

2 修改腳本

我們需要在腳本的前面加上一下2行,才能支持chkconfig命令

# chkconfig: 2345 08 92

#

# description: Automates a packet filtering firewall withipchains.

#

chkconfig:後面定義的使啟動服務的運行級別(例子中使2345啟動改服務),以及關閉和啟動服務的順序,(上例中關閉服務的順序使8,啟動的順序使92)

descriptions:對改服務的描述(上例中是ipchains包過濾),你可以換成自己想要的

修改好之後執行

cp 你的腳本 /etc/rc.d/init.d/腳本名

chmod 700 /etc/rc.d/init.d/腳本名

chkconfig --add 腳本名

例如:

將其加入Linux啟動過程,僅在level 3, level 5級別下運行

[root@Tester init.d]/sbin/chkconfig --add apache-httpd

[root@Tester init.d]/sbin/chkconfig --level 35 apache-httpdon

之後就可以了,以後每次重新啟動伺服器都會自動啟動和關閉我們的服務了
需要解決更多linux問題,詳情請看 http://www.linuxprobe.com/chapter-00.html
望採納!

③ linux怎麼讓程序開機自動啟動

1. 開機啟動時自動運行程序
Linux載入後, 它將初始化硬體和設備驅動, 然後運行第一個進程init。init根據配置文件繼續引導過程,啟動其它進程。通常情況下,修改放置在
/etc/rc或
/etc/rc.d 或
/etc/rc?.d
目錄下的腳本文件,可以使init自動啟動其它程序。例如:編輯/etc/rc.d/rc.local 文件(該文件通常是系統最後啟動的腳本),在文件最末加上一行「xinit」或「startx」,可以在開機啟動後直接進入X-Window。
2. 登錄時自動運行程序
用戶登錄時,bash先自動執行系統管理員建立的全局登錄script :
/ect/profile
然後bash在用戶起始目錄下按順序查找三個特殊文件中的一個:
/.bash_profile、
/.bash_login、
/.profile,
但只執行最先找到的一個。因此,只需根據實際需要在上述文件中加入命令就可以實現用戶登錄時自動運行某些程序(類似於DOS下的Autoexec.bat)。

④ 如何讓linux系統開機自動啟動我的程序

試試以後台方式自啟動你需要運行的程序,./app.out
&,就是在後面加上個&符號,而且我記得linux裡面自啟動程序在/etc/init.d/rcs裡面吧。

⑤ linux 怎麼配置開機自啟動

Linux如果是在
虛擬機
里的話,是無法開機自啟動的,如果是在另一個硬碟里的話,在bios里調整硬碟啟動的優先順序就可以了。

⑥ linux 怎麼把服務設置開機啟動

如果是已經安裝好的服務,需要使用chkconfig設置開機啟動。以MySQL為例,因各發行版不同,以及安裝方式的差異,伺服器的啟動腳本可能會有細微不同,現假設服務腳本文件是/etc/init.d/mysqld。
首先查看服務是否正確注冊
$ service --status-all | grep mysqld | grep -v 'grep'如果有含有mysqld文字的一行返回,則代表已正確注冊;若沒有需執行如下命令:
$ sudo chkconfig add mysqld
第二步設置開機自啟動
$ sudo chkconfig mysqld on
附:查看所有服務及其運行級別的命令
$ chkconfig --list

⑦ Linux配置開機自啟動執行腳本有哪些方法

Linux配置開機自啟動執行腳本的方法有很多,這里分享兩種方法,分別是修改/etc/rc.local方法和chkconfig管理設置的方法,均可實現Linux配置開機自啟動執行腳本的功能!
設置test.sh為開機要啟動的腳本
[root@oldboy scripts]# vim /server/scripts/test.sh
[root@oldboy scripts]# cat /server/scripts/ test.sh
#!/bin/bash
/bin/echo $(/bin/date +%F_%T) >> /tmp/ test.log
方法一:修改/etc/rc.local
[root@oldboy ~]# ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 Mar 30 10:50 /etc/rc.local -> rc.d/rc.local
修改/etc/rc.local文件
[root@oldboy scripts]# tail -n 1 /etc/rc.local
/bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null
重啟系統,查看結果
[root@oldboy ~]# cat /tmp/test.log
2018-03-30_12:00:10
方法二:chkconfig管理
刪除掉方法一的配置
[root@oldboy ~]# vim /etc/init.d/test
#!/bin/bash
# chkconfig: 3 88 88
/bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null
[root@oldboy ~]# chmod +x /etc/init.d/test
添加到chkconfig,開機自啟動
[root@oldboy ~]# chkconfig --add test
[root@oldboy ~]# chkconfig --list test
test 0:off 1:off 2:off 3:on 4:off 5:off 6:off
重啟系統,查看結果
[root@oldboy ~]# cat /tmp/test.log
2018-03-30_12:00:10
2018-03-30_12:33:20
操作成功
關閉開機啟動
[root@oldboy ~]# chkconfig test off
[root@oldboy ~]# chkconfig --list test
test 0:off 1:off 2:off 3:off 4:off 5:off 6:off
從chkconfig管理中刪除test
[root@oldboy ~]# chkconfig --list test
test 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@oldboy ~]# chkconfig --del test
[root@oldboy ~]# chkconfig --list test
service test supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add test')

⑧ 如何自定義linux服務並設置服務開機啟動

1. 服務概述
在linux操作系統下,經常需要創建一些服務,這些服務被做成shell腳本,這些服務需要在系統啟動的時候自動啟動,關閉的時候自動關閉。
將需要自動啟動的腳本/etc/rc.d/init.d目錄下,然後用命令chkconfig --add filename將自動注冊開機啟動和關機關閉。實質就是在rc0.d-rc6.d目錄下生成一些文件連接,這些連接連接到/etc/rc.d /init.d目錄下指定文件的shell腳本。

2. 手工創建服務
在/etc/rc.d/init.d目錄下創建shell腳本,文件名auto_run。
設置腳本的運行許可權chmod +x auto_run。
然後在rc0.d-rc6.d目錄下分別創建文件連接。
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc2.d/S99auto_run
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc3.d/S99auto_run
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc5.d/S99auto_run
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc0.d/K01auto_run
ln -s /etc/rc.d/init.d/auto_run /etc/rc.d/rc6.d/K01auto_run

這樣系統在啟動的時候,就會運行auto_run 並加上start參數,等同於執行命令auto_run start。
在系統關閉的時候,就會運行auto_run,並加上stop參數,等同於運行命令auto_run stop。

創建連接的6條命令可以用命令chkconfig --add auto_run來完成,這樣就簡單多了,還不容易出錯。
下面就介紹一下chkconfig命令。
3. chkconfig命令用法
語法:
chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name <on|off|reset>
chkconfig [--level levels] name

⑨ linux開機自啟動在哪裡設置

chkconfig命令設置

⑩ linux系統自啟動在哪裡設置

他的這一個自啟動一般情況都在他的這一個相應的設置裡面,你可以直接打開設置,然後把他的這一個相應的啟動程序點擊一下關閉或啟動就行。

熱點內容
新一代唐dm哪個配置最劃算 發布:2024-05-02 22:45:16 瀏覽:229
安卓怎麼安裝到sd卡 發布:2024-05-02 22:41:32 瀏覽:224
web聊天源碼 發布:2024-05-02 22:41:29 瀏覽:286
php定時腳本 發布:2024-05-02 22:18:41 瀏覽:312
雲服務可以替代普通伺服器么 發布:2024-05-02 21:57:11 瀏覽:944
wegame與伺服器斷開連接是怎麼回事 發布:2024-05-02 21:55:05 瀏覽:785
zip加密破解 發布:2024-05-02 21:41:23 瀏覽:480
怎麼模擬電腦配置 發布:2024-05-02 21:28:08 瀏覽:784
對一個新編程 發布:2024-05-02 21:20:07 瀏覽:559
華為系統編譯器在哪裡 發布:2024-05-02 21:19:50 瀏覽:86