在一個bash腳本中,我「ssh進入另一個盒子;運行1個腳本,然後運行另一個腳本;我試圖弄清楚第一個腳本運行多長時間。內聯bash時間變量擴展
#!/bin/bash
echo "Test Time Stamp"
STARTTIME=`date +%s`
ssh [email protected] 'scriptToRun.bat echo$?;/path/to/script.py '$STARTTIME `date +%s`'; exit $$?
STARTTIME和第二個date +%s
得到相同的值。
,如果我這樣做了以下
`date +%s`; sleep 10; `date +%s`
這似乎是工作。
剛開始時用'time'執行它:'time/path/to/script.sh' – fedorqui
或在ssh行後面使用日期,或者爲遠程端寫一個包裝並使用單個ssh語句'ssh user @remote timeAndExec.bat' – perreal