I am trying to make an AV bug raspberry pi for a class.
I am using sox to record sound. Which is working fine.
the issue is sox needs to be stopped by a control+C to stop and create the new file. If killall is sent from a different ssh session it will drop the other session and sox will not create the file.
listen.sh
#! /bin/bash
NOW=$( date '+%F_%H:%M:%S' )
filename="/home/pi/gets/$NOW.wav"
sox -t alsa plughw:1 $NOW.wav;
sleep 6;
echo $filename
I have tried making a separate script for stopping it; pretty much
killlisten.sh
#! /bin/bash
sleep 5;
ps | grep sox | kill 0;
Then run a
superscript.sh
#! /bin/bash
./listen.sh;
./killlisten.sh;
Any advice on how to stop sox in a way that would still produce an output file would be great. This will ideally be set to run at set times so avoiding human interaction is essential.