linux 開機啟動 自啟動 設定

2021-10-10 16:17:03 字數 604 閱讀 3121

方法一:編輯rc.loacl指令碼

ubuntu開機之後會執行/etc/rc.local檔案中的指令碼。

所以我們可以直接在/etc/rc.local中新增啟動指令碼。

$ vim /etc/rc.local
方法二:新增乙個開機啟動服務

將你的啟動指令碼複製到 /etc/init.d目錄下,並設定指令碼許可權, 假設指令碼為test

$ mv test /etc/init.d/test

$ sudo chmod 755 /etc/init.d/test

將該指令碼放倒啟動列表中去

$ cd .etc/init.d

$ sudo update-rc.d test defaults 95

注:其中數字95是指令碼啟動的順序號,按照自己的需要相應修改即可。在你有多個啟動指令碼,而它們之間又有先後啟動的依賴關係時你就知道這個數字的具體作用了。

將該指令碼從啟動列表中剔除

$ cd /etc/init.d

$ sudo update-rc.d -f test remove

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在...

Linux 設定mysql開機自啟動

1 確認 etc init.d mysql檔案是否存在 如果不存在則去mysql安裝檔案中複製乙個 cp usr local mysql support files mysql.server etc init.d mysql2 賦予可執行許可權 chmod x etc init.d mysql3 新...