태그 보관물: raspbian

raspbian

crontab에 의해 실행될 때 배쉬 조건이 충족되지 않습니다 sleep 2; done aconnect 20:0 128:0 echo “Connected” 조건

fluidsynth 서버를 시작하고 내 rasberry의 내 midi 장치에 연결하는 작은 스크립트가 있습니다 (OS는 raspbian stretch lite입니다).

echo  "Starting"
fluidsynth -is -a alsa --gain 3 /usr/share/sounds/sf2/Nice-Keys-B-Plus-JN1.4.sf2 &
echo "Fluidsynth started"
while true; do aconnect -o; if [[ $(aconnect -o ) = *FLUID* ]]; then break; fi; sleep 2; done
aconnect 20:0 128:0
echo "Connected"

조건 외부의 aconnect -o는 디버깅을위한 것입니다.

정상적으로 실행하면 (./startup_fluid_synth.sh) https://pastebin.com/kU0wDu3w가 정상적으로 작동합니다.

내 crontab -e는 말합니다.

@reboot /home/pi/startup_fluid_synth.sh >> /home/pi/fluid.log

이제 pi를 다시 설정하면 스크립트가 시작되지만 로그는 조건이 충족되어야 함을 명확하게 표시하지만 다음 조건을 충족하지 않아야합니다. https://pastebin.com/FnxMKBkF

왜 이것이 될 수 있는지 아십니까?

업데이트 :
오류 로그에 다음이 표시됩니다.

/home/pi/startup_fluid_synth.sh: 4: /home/pi/startup_fluid_synth.sh: [[: not found

cron이 어떻게 든 [[]] 명령을 알지 못할 가능성이 있습니까?



답변

#! / bin / bash를 .sh 파일에 추가하면 문제가 해결되었습니다.

#!/bin/bash
echo  "Starting"
/usr/bin/fluidsynth -is -a alsa --gain 3 /usr/share/sounds/sf2/Nice-Keys-B-Plus-JN1.4.sf2 &
echo "Fluidsynth started"
while true; do /usr/bin/aconnect -o; if [[ $(/usr/bin/aconnect -o ) = *FLUID* ]]; then break; fi; sleep 2; done
/usr/bin/aconnect 20:0 128:0
echo "Connected"

답변