이 스크립트를 실행할 때 8 행에 구문 오류가 발생하는 이유는 무엇입니까? 예를 들어 i = 2를 설정하고 관련 라인 6과 8을 콘솔에 복사하면 정상적으로 작동합니다.
#! /bin/bash
# kills MATLAB if a GPU reaches a threshhold temperature
while true
do
gputemps=$(nvidia-smi --query-gpu=index,temperature.gpu --format=csv,noheader)
for i in 2 4 6 8
gputemp=$(echo ${gputemps} | awk -v var=$i '{print $var}')
if [ $gputemp -ge $1 ]
then
killall MATLAB
fi
done
sleep 1m
done
스크립트가 제대로 작동하려면 4 개의 Nvidia GPU가 필요하거나 for 루프를 사용하는 대신 i = 2를 설정하는 경우 적어도 하나가 필요합니다. Ubuntu 16.04를 실행하고 있습니다.
이 시도:
#! /bin/bash
# kills MATLAB if a GPU reaches a threshhold temperature
while true
do
gputemps=$(nvidia-smi --query-gpu=index,temperature.gpu --format=csv,noheader)
for i in 2 4 6 8
do
gputemp=$(echo ${gputemps} | awk -v var=$i '{print $var}')
if [ $gputemp -ge $1 ] then
killall MATLAB
fi
done
sleep 1m
done
당신은 누락 된 do
당신을 위해 for loop
.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다