tempest766 wrote: ↑
Fri Jan 18, 2019 10:07 pm
why are you doing this in cron? Cron is not for running things on reboot. it is for running tasks on a regular periodic basis.
put it in /etc/rc.local instead.
That's exactly the opposite of what you should do. Most linux distributions (including debian, which raspbian is forked from) have deprecated (i.e. removed or marked for removal) /etc/rc.local. And if cron didn't want to run things at reboot why does the "@reboot" tag exist? rc.local use can also cause more problems that it solves. if you get it wrong and something fails (or never returns) you'll see a boot error logged and anything after it in rc.local won't even get the chance to run. With cron, only the failed job fails and the failure won't be treated as a failure to boot.
Don't want to use cron for @reboot jobs? That's fine but don't use /etc/rc.local either. Use a systemd service. Or use rc.local but be prepared for it to break with a future OS upgrade.
That said, the likely cause is not the PATH but that cron is running the OP's script before the network is up so it exits with an error. Which is lost as cron will throw away all output.
Debugging this stuff is straight forward.
First, change your crontab entry to
Code: Select all
@reboot /home/pi/myscripts/startmusic.sh >/home/pi/myscripts/startmusic.log 2>&1
You can then examine the contents of /home/pi/myscripts/startmusic.log for output and error messages.
Once you know the error, you're on the way to fixing it. If you're not sure what it means or how to go about fixing it, post the error log here.