The following scripts work if I run them manually in SSH, but when I put them in as cron jobs, it fails.
BTConnect.sh
Code: Select all
#!/bin/bash
#/usr/bin/pulseaudio -D --system
/usr/bin/sudo service bluetooth restart
/bin/sleep 10
#/usr/bin/pactl load-module module-bluetooth-discover
/usr/bin/pactl list sinks short
/bin/sleep 5
/usr/bin/bluetoothctl << EOF
connect 96:13:5A:00:5D:E6
EOF
/bin/sleep 15
/usr/bin/pactl set-source-volume 0 65535
/usr/bin/pactl list sinks short
/usr/bin/pactl load-module module-loopback source=0 sink=1 rate=44100 adjust_time=0
/usr/bin/mplayer --volume 35 -shuffle -ao pulse Music
Code: Select all
#!/bin/bash
/usr/bin/pkill mplayer
/usr/bin/bluetoothctl << EOF
disconnect 96:13:5A:00:5D:E6
EOF
/usr/bin/pulseaudio -k
I run BTConnect.sh manually to play the music in the Music folder and then run BTKill.sh to stop playing.
These are all in my /home/pi folder.
When the above '/usr/bin/pactl load-module module-loopback source=0 sink=1 rate=44100 adjust_time=0' executes, I get:
Code: Select all
0 alsa_output.platform-soc_audio.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
1 bluez_sink.96_13_5A_00_5D_E6.a2dp_sink module-bluez5-device.c s16le 2ch 44100Hz SUSPENDED
Here's my cron job (created as ''Pi' user, not Root):
Code: Select all
0,10,20,30,40,50 * * * * /home/pi/BTConnect.sh >>/home/pi/BTConnect.log&
5,15,25,35,45,55 * * * * /home/pi/BTKill.sh >>/home/pi/BTKill.log&
What am I missing here?