從 /etc/rc.local 執行多個無限循環腳本

從 /etc/rc.local 執行多個無限循環腳本

我想在啟動系統時運行 3 個無限循環腳本,我的想法不起作用:

##!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
cd /
cd home
cd pi
cd steamidle
node lostkiko1.js &
node lostkiko2.js &
node d.js

exit 0

它只運行第一個腳本(如果有)。我認為原因很清楚:它停留在第一個,因為它是無止境的......我不知道如何解決這個問題。有人有嗎?謝謝你!

答案1

不要使用cd它是多餘的。使用完整路徑,例如node /home/pi/steamidle/lostkiko1.js &另外,您的最後一個腳本也應該以 結尾&,因為 shell 一直等待您rc.local退出,因此它會阻止其他進程。

答案2

您可以為「啟動應用程式」應用程式中的每個腳本新增單獨的條目。

按 Super 鍵調出 Dash 搜尋並蒐索「啟動應用程式」。可以為每個腳本新增一個條目。例如,對於第一個命令,添加“node /home/pi/steamidle/lostkiko1.js”作為命令。

相關內容