[SATLUG] Cron Jobs: Somewhat solved...

Marc Ripley misteratomic at gmail.com
Sat Jan 24 11:42:45 CST 2009

I've found a temporary work around for my radio recording cron jobs.
I set up a root cron job which runs the following script.
I then change ownership of the file to me and no problems.

recdate1=`date +%y_%m_%d`
echo "C2C_"$recdate1"_HR1 Recorded: $(date)" >> /tmp/croncheck.log
cd /home/myusername/Desktop
/usr/bin/arecord -d 3300 -c 1 -f S16 -r 32000 -D hw:2,0 C2C_"$recdate1"_H1.wav
/usr/bin/lame -v -V9 C2C_"$recdate1"_H1.wav C2C_"$recdate1"_H1.mp3
rm -f C2C_"$recdate1"_H1.wav
chown myusername:myusername C2C_"$recdate1"_H1.mp3

You will notice that I now use a variable instead of hard coding the
date in the filename for the script.  This was necessary due to one of
my recordings starting one day and finishing a few minutes into the
next day.  When the script looked to find a file to delete, it asked
for the wrong file.  Took me a while to figure out the syntax to pass
a variable!  Ha ha...

I would however like to run these scripts as myself (regular log-n).
Since the problem is no longer an issue due to the temp workaround, no
rush to figure it out.  However, the nagging thing at the back of my
mind is how to allow my non-root user cron jobs have use of and access
to sound hardware.

Any hints?

More information about the SATLUG mailing list