나는 Fluidsynth 서버를 시작한 다음 이를 내 라즈베리의 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
이제 파이를 재부팅하면 스크립트가 시작되지만 로그에는 조건이 충족되어야 한다고 명확하게 표시되지만 그렇지 않습니다.https://pastebin.com/FnxMKBkF
왜 이런 일이 일어날 수 있는지 아십니까?
업데이트: 오류 로그에 다음이 표시됩니다.
/home/pi/startup_fluid_synth.sh: 4: /home/pi/startup_fluid_synth.sh: [[: not found
cron이 어떻게든 [[ ]] 명령을 모를 가능성이 있습니까?
답변1
.sh 파일에 #!/bin/bash를 추가하면 문제가 해결되었습니다.
#!/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"