LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cron problems (https://www.linuxquestions.org/questions/linux-newbie-8/cron-problems-4175507190/)

rmcellig 06-05-2014 07:25 PM

Cron problems
 
I'm still trying to nail down the problem and hopefully someone can help me.

When I run my code from the terminal, it works. When it is run from Cron, there is no recording. The file is created but when I open it, nothing. No sound, and the file size stays at 44k. When I run from the terminal, I can see the file size increasing when I look at it from a thunar window.

Any idea what is going on and what I should do?

This is the code I am using:

Code:

arecord -t wav -f cd -d 44 /home/randy/chuo-radio-shows/testaudioJUN0514.wav
Here is the crontab entry :

Code:


9 11 * * 4 arecord -t wav -f cd -d 44 /home/randy/chuo-radio-shows/testaudioJUN0514.wav


I am using LinuxLite 2.0 which is based on Ubuntu 14.04

Emerson 06-05-2014 07:30 PM

Tried using full path to arecord?

kooru 06-05-2014 10:59 PM

Usually when a command works from the terminal but not from cron, it needs to specify the full path.
Because environment variables for cron is different from those about your user.

rmcellig 06-06-2014 04:07 AM

Haven't tried that.Will see if that resolves my problem. What does the full path look like? Thanks!!

pan64 06-06-2014 04:20 AM

full path means you start it with a slash / and will point to the file you want to execute. For example ls is located in /bin, therefore it is /bin/ls using full path. Also man is located in /usr/bin, it will be /usr/bin/man.
So execute the command which arecord, that will show you the full path to arecord and use that in your crontab:
9 11 * * 4 /full/path/to/arecord -t wav -f cd -d 44 /home/randy/chuo-radio-shows/testaudioJUN0514.wav

rmcellig 06-06-2014 04:28 AM

So it is the full path to arecord? That's interesting. I thought you meant full path to the .wav file which I already used. Thanks for this info!!

I will post back with my results. I learned something new. Thanks again!

Emerson 06-06-2014 06:26 PM

The echo command below prints your user environment path.
Code:

~ $ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.2:/usr/games/bin

You can see if you are in your user environment the arecord is in your path, so it will be found even if you do not specify full path.
Code:

~ $ which arecord
/usr/bin/arecord

OTOH, cronjob does not run in your user environment (it does not log in as you), thus plain arecord will not be found.

jpollard 06-07-2014 08:01 AM

I suspect the full path won't help - after all, the output file wouldn't be created if it didn't run.

What I think is happening is that arecord doesn't have access to the audio source, thus getting either an EOF and exiting, or creating an error message.

Audio device access isn't something that cron would enable.


All times are GMT -5. The time now is 07:01 AM.