我在一個系統上連接了 10 個 GPU,想用所有 GPU 進行挖礦,因為 ubuntu GUI 不允許一次運行 10 個 GPU,所以將使用命令列並能夠在那裡進行挖礦。
現在我想在系統啟動時運行我的礦工,特別是我正在關注的這教程(步驟 7)。我已按照教程完成了所有操作,但無法在螢幕會話中啟動 ./start_only_eth.bash 命令(未建立螢幕會話)。
如果我執行以下命令,我可以使用“screen -ls”命令找到此會話。
screen -dmS ethm
下面是我的腳本(demo.sh)
// 更新
#!/bin/bash
DEFAULT_DELAY=0
if [ "x$1" = "x" -o "x$1" = "xnone" ]; then
DELAY=$DEFAULT_DELAY
else
DELAY=$1
fi
sleep $DELAY
su aman -c "screen -dmS ethm /home/aman/Desktop/claymore/start_only_eth.bash"
我已在 rc.local 檔案中新增了此腳本的路徑,如中所述這教程(步驟 7)。
下面是我的 rc.local
#!/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.
sh '/home/aman/Desktop/demo.sh'
exit 0
重新啟動後,如果我執行“screen -ls”命令,我會收到以下訊息
No Sockets found in /var/run/screen/S-aman.
注意:我認為問題不在rc.local中,問題在demo.sh中。如果嘗試手動執行 demo.sh,腳本將失敗並收到上述訊息。
// // -------------------------- 使用 TMUX ------------------ -- // //
我也用 tmux 嘗試過,這次我能夠在 tmux 會話中運行礦工(手動),但再次無法使用 rc.local 運行腳本,因為下面是我的 demo.sh
#!/bin/bash
tmux new-session -d -n MINER
tmux send-keys -t MINER "cd /home/aman/Desktop/claymore" C-m
tmux send-keys -t MINER "./start_only_eth.bash" C-m
以下是我在嘗試測試 rc.local 時得到的結果(控制台)
aman@aman-System-Product-Name:~$ sudo /etc/init.d/rc.local start
[sudo] password for aman:
[ ok ] Starting rc.local (via systemctl): rc.local.service.
答案1
cd /home/Desktop/claymore
su aman -c "screen -dmS ethm ./start_only_eth.bash"
這有很多問題。首先,路徑很可能是/home/username/Desktop/claymore
。其次,cd
影響當前腳本,並且可能不會透過 su 轉移到螢幕上。
嘗試:
su aman -c "screen -dmS ethm /home/username/Desktop/claymore/start_only_eth.bash"
如果腳本start_only_eth.bash
需要將 PWD 設定為該目錄,請放置一行
cd /home/username/Desktop/claymore
作為腳本的第二行。
替換username
為實際使用者名稱。