Unable to start direwolf using cron

Prerequisites:

  • Raspberry Pi running up to date Buster
  • rtl_fm has been installed and successfully tested
  • SDR dongle has been calibrated
  • direwolf has been installed and configurated
  • rtl_fm and direwolf can be started without errors using the command line

At this stage rtl_fm + direwolf couldn’t be started using a cron job as described in the direwolf documentation.

The solution for this issue is a small adjustment of the script ‘dw-start.sh’. It’s a good habit to create a backup of the script with the command

cp dw-start.sh dw-start.backup

Then change two lines in this script as below:

DWCMD="bash -c 'rtl_fm -f 144.8M - | direwolf -c sdr.conf -r 24000 -D 1 -'"

becomes:

dwcmd() { bash -c 'rtl_fm -f 144.8M - | direwolf -c sdr.conf -r 24000 -D 1 -'; }

Followed by:

$SCREEN -d -m -S direwolf $DWCMD >> $LOGFILE

becomes:

$SCREEN -d -m -S direwolf $(dwcmd) >> $LOGFILE

Now the script dw-start.sh can be added to cron:

crontab -e
* * * * * /home/pi/dw-start.sh > /dev/null 2>&1

This modification has been posted before at Github by KX3F.