Linux設定程式的開機自啟動與Linux服務

2021-04-23 14:59:06 字數 892 閱讀 6400

這裡只說我所知道的,舉例如下

需求是我要用windows下的vnc viewer連線到linux

server. 我在linux下面輸入

#vncserver

設定好密碼,好現在我就可以在windows下面使用vnc連線到linux桌面了,這個時候如果我的linux server系統重啟了,那麼我還得再敲一次vncserver這個命令,所以我現在要讓linux server在開機時自動啟動vncserver

有哪些方法呢?

1. 我可以把vncserver設定成系統的服務,並啟動起來,使用如下命令檢視vncserver是否已經是系統的服務

#chkconfig --list|grep vnc

vncserver       0:off   1:off   2:off   3:off   4:off   5:off    6:off

現在我們要設定vncserver開機自啟動,使用如下命令

#chkconfig --level 5 vncserver on#chkconfig --list|grep vnc

vncserver       0:off   1:off   2:off   3:off   4:off   5:on    6:off

這個時候重啟系統,那麼vncserver就會以服務的方式自動起來,但是現在如果想立即使用vnc則直接敲命令 vncserver即可

2. 我們可以把vncserver這條命令寫在linux開機要執行的指令碼裡面,那些指令碼是linux開機時要執行的呢?

我知道的有以下這些:

/etc/rc.local

/etc/rc.sysinit

/etc/inittab

/etc/profile

這裡記住linux服務於linux開機自啟動之間的區別和聯絡

linux開機自啟動程式設定方法

linux如何開機執行自己的程式呢?搞了幾天終於搞定。1.首先在自己的工程檔案裡編寫自啟動shell檔案,這是我的例子如下 檔案名字 testudp.sh 可執行程式為tst client bin sh begin init info provides tst client required sta...

Linux 設定開機自啟動

執行命令 編輯 etc rc.local 新增你想開機執行的命令 執行程式指令碼 然後在檔案最後一行新增要執行程式的全路徑。例如,每次開機時要執行乙個hello.sh,這個指令碼放在 usr下面,那就可以在 etc rc.local 中加一行 usr hello.sh 或者 cd opt hello...

Linux設定開機自啟動

執行程式指令碼 然後在檔案最後一行新增要執行程式的全路徑。例如,每次開機時要執行乙個hello.sh,這個指令碼放在 usr下面,那就可以在 etc rc.local 中加一行 usr hello.sh 或者 cd opt hello.sh 注意,你的命令應該新增在 exit 0 之前 linux在...