Perplexing Cron audio problem
I'm running LinuxLite 2.0 32bit on a Dell 3000.
I have never come across anything like this and to tell you, I am stumped. Here are the contents of my crontab file: Code:
# Edit this file to introduce tasks to be run by cron. If I run this from the terminal, everything is fine. It properly records the audio: Code:
/usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav Code:
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav This recorded at 2:15pm on Tuesday (today) but no audio. Yet if I run the code as mentioned above, from the terminal without the cron settings, the recording is fine. Any ideas what I should do? |
The first thing that comes to mind is that cronjobs will not load any environment variables that your shell will have set when it loads your .bashrc and other profile files. Are there any environment variables you can see being set that would have any affect on your arecord binary?
Im not familiar with arecord so not sure how it works but I would assume that its an environment variable |
Yea looks like its environment variables.
Couldnt find really anything online except the archwiki which describes it. Should translate to any distro as its a standalone binary. Try creating a .asoundrc file with the values set and call that in your cronjob script. https://wiki.archlinux.org/index.php...nment_variable |
A trial gives the following:-
Code:
zzz=$(date "+\%^b\%d\%y") |
For some reason things seem fine now. I will keep an eye out for any other anomalies. At the moment, I have several Crons recording at different hours to see if everything is OK.
Thanks for the tips!! Regarding the .asoundrc file mentioned above, where would I create this file, exactly what would I enter in the file and finally how do I call this in my cronjob script. This is a new one for me so I want to make sure I get everything right and learn from it. Thanks again!!!! |
Quote:
A good interview question I ask is: "A file has been created named * at /. How would you delete the file with rm without removing anything else?" |
rmcellig,
please take a look at the links provided. It is going to be your environment variable for hte default soundcard/microphone as those get set when you start a shell but not when a cron job is run. If the same command works when run manually and you are not getting an error that a file is not found its not an issue with a file path. |
Thanks!!
|
I have Zorin 9 lite and Linux Lite 2.0 in seperate partitions on my Dell 3000. In Zorin, I have no problems at all recording from my crontab. The problem appears in Linux Lite. Why is this and what can I check in Zorin that may be missing in Linux Lite that may resolve my problem? I'm so new to all of this but at the same time I want to learn why these things happen.
If there is any info you would like me to post back while booted into Linux Lite, let me know. Thanks again!! |
Still not working
I just did a brand new installation of Linux Lite 2.2 on my Dell 3000. Cron still doesn't work. No audio. Works when I run the following from the terminal but not in my crontab. I tried to keep the code as simple as possible.
Run from Crontab: Code:
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 44 /home/randy/Music/test.wav Code:
/usr/bin/arecord -t wav -f cd -d 44 /home/randy/Music/test.wav |
do you get any errors? crontab will send errors to your linux email (type mail in terminal) of output it has. You can also redirect the output by using > or >>
Code:
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 44 /home/randy/Music/test.wav &>> /tmp/cron_arecord.log Also crontab uses sh, not bash. I don't see anything that should be of issue, but in terminal try typing sh, then typing or copying in your command. Quote:
& if you're unsure, use autocomplete & -i. Do I get a job? ;) |
This is what I get :
Code:
|
Quote:
In a terminal, type in sh then hit enter. This enters the sh shell. Then type in the script name It'll look like this: Code:
~ $ sh Code:
~ $ echo $(date "+\%^b\%d\%y").wav |
Quote:
The GUI login generally sets up access permissions to allow GUI interfaces to have access. When logged out, access is denied as it could be a security violation (as in surreptitious recording of data where people believe they are in private). My system has two users (me, and my wife). When both of our logins are active, only the one with the GUI is granted access, and the other is disabled - providing nothing, and playing nothing. When the other switches in, and logs in (usually the screen saver), then the sound resumes - and the other is disabled. |
Just guessing. You need to identify what user it is running as under cron (nobody?). And ensure that user has access (audio group?) and write permissions to the destination. Check the /etc/default/cron file for settings, and maybe change the logging level and check /var/log/ for why it's failing. Or if it's failing, I tend to stop cron entirely on my desktop installs. I'm not a big fan of logfile rotations in the middle of a boss fight. Or 6:25am noisy drive alarm clocks.
|
All times are GMT -5. The time now is 10:41 AM. |