Ubuntu 創建開機啓動腳本的一種方法(rc.local)
#
1、編輯/etc/rc.local
如:sudo vim /etc/rc.local
在 exit 0之前添加腳本代碼
如:sh /ect/ifconfig.sh
rc.local:
1 #!/bin/sh -e
2 #
3 # rc.local
4 #
5 # This script is executed at the end of each multiuser runlevel.
6 # Make sure that the script will "exit 0" on success or any other
7 # value on error.
8 #
9 # In order to enable or disable this script just change the execution
10 # bits.
11 #
12 # By default this script does nothing.
13
14 sh /etc/ifconfig.sh
15
16 exit 0
2.在/etc/目錄下創建腳本文件(必須在該目錄下,其他目錄沒成功,不知道爲什麼,希望看見的大神解答下,謝謝)
如:sudo vim ifconfig.sh
1
2 cd /home/sunny/test/ && \
3 ifconfig > README && \
4 git add README && \
5 git commit -m "test2" && \
6 git push -u origin master
1、編輯/etc/rc.local
如:sudo vim /etc/rc.local
在 exit 0之前添加腳本代碼
如:sh /ect/ifconfig.sh
rc.local:
1 #!/bin/sh -e
2 #
3 # rc.local
4 #
5 # This script is executed at the end of each multiuser runlevel.
6 # Make sure that the script will "exit 0" on success or any other
7 # value on error.
8 #
9 # In order to enable or disable this script just change the execution
10 # bits.
11 #
12 # By default this script does nothing.
13
14 sh /etc/ifconfig.sh
15
16 exit 0
2.在/etc/目錄下創建腳本文件(必須在該目錄下,其他目錄沒成功,不知道爲什麼,希望看見的大神解答下,謝謝)
如:sudo vim ifconfig.sh
1
2 cd /home/sunny/test/ && \
3 ifconfig > README && \
4 git add README && \
5 git commit -m "test2" && \
6 git push -u origin master
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.