Sample Header Ad - 728x90

IF statment for checking if arecord is working inside a shell script no responding well

0 votes
1 answer
277 views
I wrote a script that should check if the arecord command line audio recorder is not working, and if so it should start it. With the help of cron, I want to verify that I'm recording within a specific time frame. Thid is because sometimes the arecord stop without any warning. Here is my script (a shell executable file) I run with cron: #!/bin/sh dateis=$(date +"%Y-%m-%d-%H-%M") if [pgrep -x "arecord" >/dev/null] then else arecord -v -f dat -r 48 -D hw:1,0 -d 200 -c 2 | lame -r -h - record-$dateis.mp3 fi For some reason, even when the arecord is recording, it tries to start another instance of arecord. On the command line, the pgrep is indicating properly. But for some reason it won't stop and would ignore the if statment. It starts recording even though it is running at the same moment. Hope I made this issue clear.
Asked by Asaf Chertkoff (111 rep)
Dec 22, 2020, 11:15 PM
Last activity: Dec 24, 2020, 03:21 PM