簡體   English   中英

在本地計算機上運行Shell腳本,並在AWS EC2實例上運行腳本-如何跟蹤ongion輸出?

[英]running a shell script on my local computer that runs a script on aws ec2 instance - How can I follow the ongion output?

我在本地計算機上運行外殼程序腳本,該計算機最終連接到我的aws ec2實例,並在此計算機上運行另一個外殼程序腳本:

   ssh -i key.pem ubuntu@$host "bash run_file.sh ${userInput}"

另一個shell腳本“ run_file.sh”如下所示:

#!/bin/bash

PATH=/home/ubuntu/anaconda3/bin:$PATH
source activate pytorch_p36
cd local_directory/libcpab-master/
echo "running ${1}..."
python ${1}

腳本運行后,我將在終端中獲取所有輸出,但我想跟蹤正在進行的輸出。 如何才能做到這一點? 如果可能的話。

您可以將實時輸出和錯誤發送到文件中,打開第二個窗口,然后使用tail -f選項實時檢查輸出。 您的ssh命令將如下所示:

ssh -i key.pem ubuntu@$host "bash run_file.sh ${userInput} 1>/path/to/logfile 2>>/path/to/logfile "

該文件將在您通過ssh連接的服務器上生成。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM