2

I have a small script to start a fluidsynth server and then connect it to my midi device on my rasberry (OS is 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"

The aconnect -o outside of the condition is for debugging.

When I executed normally (./startup_fluid_synth.sh) it works fine: https://pastebin.com/kU0wDu3w

My crontab -e says:

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

Now when I reboo the pi, the scripts starts up, but the log clearly shows that the condition should be met, but isn't: https://pastebin.com/FnxMKBkF

Any idea why this could be?

Update: Error log shows:

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

Is it possible that cron doesn't know the [[ ]] command somehow?

4
  • Use full path to aconnect (and any other external commands).
    – choroba
    Feb 2, 2018 at 12:08
  • Tried that already, how would that result in a condition not being met, when the command is clearly executed normally?
    – Julian
    Feb 2, 2018 at 12:16
  • It seems the fluidsynth command hasn't started. Can you check the error output of the script as well?
    – choroba
    Feb 2, 2018 at 12:25
  • If you look at line 119 from the 2nd pastebin you'll see that the fluidsynth starts, i'll add the error output and post it above.
    – Julian
    Feb 2, 2018 at 12:42

1 Answer 1

1

Adding #!/bin/bash to the .sh file solved the issue.

#!/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"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .