centOS 開機自啟動自己的指令碼

2022-09-15 20:09:33 字數 774 閱讀 9692

1. 自己指令碼 myservice 如下:

#!/bin/bash

# chkconfig:

2345

1090

# description: myservice ....

echo

"hello world

" > /tmp/hello.log

2. 將自己寫的指令碼move到 /etc/rc.d/init.d/ 下面並修改許可權

mv myservice /etc/rc.d/init.d/

chmod +x myservice

3. 將指令碼加入開機服務

chkconfig --add myservice             #把myservice新增到系統服務列表

chkconfig myservice on #設定myservice的開關(on/off)

chkconfig --list myservice #就可以看到已經註冊了myservice的服務

備註:自己寫的指令碼myservice 中如果# chkconfig: 2345 10 90與 # description: myservice .... 這兩行沒有寫會報錯  「service myservice does not support chkconfig」

因為chkconfig 會讀這兩行並配置服務的優先順序;

centOS 開機自啟動配置

centos 配置開機自啟動兩種方式 1.vi etc rc.d rc.local 在此檔案中加入啟動的指令碼 2.chkconfig 增加指令碼 chkconfig add 指令碼名稱 增加開機自動啟動指令碼 list 檢視開機自動啟動的指令碼 del 取消開機自動啟動指令碼 步驟 1.自己定義指...

CentOS 開機自啟動指令碼

開機時執行自己的指令碼.1.編寫自己的服務指令碼 進入系統服務指令碼目錄 cd etc rc.d init.d vi test 內容如下 bin bash chkconfig 57 75 description test service start stop see how we were call...

CentOS 開機自啟動指令碼

開機時執行自己的指令碼.1.編寫自己的服務指令碼 進入系統服務指令碼目錄 cd etc rc.d init.d vi test 內容如下 bin bash chkconfig 57 75 description test service start stop see how we were call...