centos rc.local 啟動不了怎么辦

centos rc.local啟動不了的解決辦法:1、查看“rc.loca”腳本內容;2、將文件“rc.local”加上可執行權限即可。

centos rc.local 啟動不了怎么辦

本文操作環境:centos7系統、Dell G3電腦。

centos rc.local 啟動不了怎么辦?

centos7-rc.local文件程序開機不能自啟動?

centos7系統中,發現rc.local里程序開機不能自啟動:

1、查看rc.loca腳本內容

[root@web01?~]#?cat?/etc/rc.d/rc.local #!/bin/bash #?THIS?FILE?IS?ADDED?FOR?COMPATIBILITY?PURPOSES # #?It?is?highly?advisable?to?create?own?systemd?services?or?udev?rules #?to?run?scripts?during?boot?instead?of?using?this?file.  #這是強烈建議您創建自己的systemd服務或udev規則在啟動運行腳本而不是使用這個文件 ? #?In?contrast?to?previous?versions?due?to?parallel?execution?during?boot #?this?script?will?NOT?be?run?after?all?other?services. #相比之前的版本啟動期間由于并行執行此腳本將不會運行畢竟其他服務。 ? #?Please?note?that?you?must?run?'chmod?+x?/etc/rc.d/rc.local'?to?ensure #?that?this?script?will?be?executed?during?boot. #請注意,您必須運行chmod?+?x?/etc/rc.d/rc.local,來確保執行開機啟動該腳本。

2、驗證1中所說的

結果查看權限時發現,rc.locat是鏈接文件,且沒有可執行權限,rc.d有可執行權限。

[root@cc?~]#?ll?/etc/rc.local lrwxrwxrwx.?1?root?root?13?Jan?9?20:51?/etc/rc.local?->?rc.d/rc.local ? [root@cc?~]#?ll?/etc/rc.d/rc.local -rw-r--r--.?1?root?root?531?May?22?21:42?/etc/rc.d/rc.local ? [root@cc?~]#?ls?-ld?/etc/rc.d/ drwxr-xr-x.?10?root?root?127?May?22?21:42?/etc/rc.d/

3、解決問題

接下來只需將文件rc.local加上可執行權限即可:

[root@cc?~]#?chmod?+x?/etc/rc.d/rc.local ? [root@cc?~]#?ll?/etc/rc.d/rc.local -rwxr-xr-x.?1?root?root?531?May?22?21:42?/etc/rc.d/rc.local

總結,之前只是在rc.local腳本中添加要開機啟動的程序,并沒有在意腳本中的說明,所以出錯了。注釋很重要,教你怎么用。  

推薦教程:《centos教程

以上就是

? 版權聲明
THE END
喜歡就支持一下吧
點贊7 分享