2017-07-24 82 views
1

我有一個存儲在每天晚上重新啓動的工作站上的聊天工具。現在它重新啓動並在啓動時爲機器人運行腳本,而無需任何人登錄。通常,它將在那段時間連接到網絡,但如果連接網絡需要更長時間,腳本將退出錯誤。連接到網絡後啓動腳本

我試過將它添加到rc.local文件中,我也嘗試在init.d目錄中放置一個自定義腳本並運行 update-rc.d script.sh defaults

一旦計算機連接到網絡而沒有任何人需要登錄,我將編輯哪個文件來運行我的腳本?

我試過四處尋找,並看到很多事例,一旦你登錄的工作,我也看到this answer,看起來可能是正確的軌道?

--update--

我一直在讀入/etc/network/if-up.d/,看看腳本被放置在那裏,標記爲可執行沒有.sh擴展,它應該運行。 Debian的文檔herehere解釋:

The ifupdown system automatically runs scripts installed in- 
"/etc/network/*/" while exporting environment variables to scripts. 

The ifupdown-extra package provides easy network connection tests for use 
with the ifupdown package. 

    -The network-test(1) command can be used from the shell. 

    -The automatic scripts are run for each ifup command execution. 

The network-test command frees you from the execution of cumbersome low 
level commands to analyze the network problem. 

The automatic scripts are installed in "/etc/network/*/" and perform the following: 

    -Check the network cable connection 

    -Check duplicate use of IP address 

    -Setup system's static routes based on the "/etc/network/routes" definition 

    -Check if network gateway is reachable 

    -Record results in the "/var/log/syslog" file 

這個過程中是否會出現在啓動?如果一個腳本放在這裏,它只會在沒有人需要登錄的情況下建立連接時運行嗎?如果連接的建立之前我的腳本運行時,它會因不能沒有來自主機的響應,將需要手動運行一次有人用武之地。

--update--

腳本不當計算機重新啓動並連接到網絡上正在執行,我試圖尋找到爲什麼讀這個答案here和NetworkManager.conf變化值從

[ifupdown] 
managed=false 

[ifupdown] 
managed=true 

我錯過了什麼?我知道腳本沒有被調用,因爲它應該輸出到日誌中,但日誌永遠不會出現。

+1

看看'/ etc/network'文件夾... – arkascha

+0

@arkascha我更新了我的問題!感謝您的支持 –

+0

顯然,放置在那裏的腳本在「啓動」時也會被考慮,因爲它使用這個系統來提取網絡接口。顯然,一旦網絡接口被拉高,腳本就會被執行。這意味着您可能需要檢查腳本_which_界面開始的腳本。你會在現有的腳本中找到這樣的例子,'openssh-server'腳本是一個很好的起點。 – arkascha

回答

0

到現在爲止,一切都正確完成。我讀this回答並跑

sudo ifup --all -v 

它已經顯示我在我的腳本中有語法錯誤。修復後,它按預期工作。