LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-07-2014, 05:28 PM   #1
rmcellig
Member
 
Registered: Sep 2009
Posts: 252
Blog Entries: 1

Rep: Reputation: 24
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.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav

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
If I run this as it is shown in my crontab file, it records but there is no audio recorded.:


Code:
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav
What could be causing this? I tried different cron settings for example 15 14 * * 2

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?
 
Old 10-07-2014, 05:45 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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
 
Old 10-07-2014, 05:52 PM   #3
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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
 
Old 10-07-2014, 05:52 PM   #4
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
A trial gives the following:-
Code:
zzz=$(date "+\%^b\%d\%y")
echo $zzz
\OCT\07\14
Perhaps you could try $(date "+/%^b/%d/%y")
 
Old 10-07-2014, 05:56 PM   #5
rmcellig
Member
 
Registered: Sep 2009
Posts: 252

Original Poster
Blog Entries: 1

Rep: Reputation: 24
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!!!!

Last edited by rmcellig; 10-07-2014 at 06:37 PM.
 
Old 10-07-2014, 05:57 PM   #6
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Quote:
Originally Posted by JeremyBoden View Post
A trial gives the following:-
Code:
zzz=$(date "+\%^b\%d\%y")
echo $zzz
\OCT\07\14
Perhaps you could try $(date "+/%^b/%d/%y")
That could very easily be a valid structure, not something a Linux guy likes to see but you can create files with "\" in it or whatever character you want.

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?"
 
Old 10-07-2014, 05:58 PM   #7
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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.
 
Old 10-07-2014, 08:15 PM   #8
rmcellig
Member
 
Registered: Sep 2009
Posts: 252

Original Poster
Blog Entries: 1

Rep: Reputation: 24
Thanks!!
 
Old 10-09-2014, 11:26 AM   #9
rmcellig
Member
 
Registered: Sep 2009
Posts: 252

Original Poster
Blog Entries: 1

Rep: Reputation: 24
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!!
 
Old 01-06-2015, 06:03 PM   #10
rmcellig
Member
 
Registered: Sep 2009
Posts: 252

Original Poster
Blog Entries: 1

Rep: Reputation: 24
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
Run from the Terminal:
Code:
/usr/bin/arecord -t wav -f cd -d 44 /home/randy/Music/test.wav
 
Old 01-06-2015, 08:41 PM   #11
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
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
Look through that to see if anything pops up.
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:
"A file has been created named * at /. How would you delete the file with rm without removing anything else?"
Escape it? :P rm -i /\*
& if you're unsure, use autocomplete & -i.
Do I get a job?

Last edited by Miati; 01-06-2015 at 08:47 PM.
 
Old 01-07-2015, 06:27 AM   #12
rmcellig
Member
 
Registered: Sep 2009
Posts: 252

Original Poster
Blog Entries: 1

Rep: Reputation: 24
This is what I get :

Code:
randy@lin3000:~$ sh /usr/bin/arecord -t wav -f cd -d 84 /home/randy/Music/chu3.wav
/usr/bin/arecord: 1: /usr/bin/arecord: Syntax error: word unexpected (expecting ")")
randy@lin3000:~$
 
Old 01-07-2015, 10:12 AM   #13
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
Quote:
Originally Posted by rmcellig View Post
Code:
randy@lin3000:~$ sh /usr/bin/arecord -t wav -f cd -d 84 /home/randy/Music/chu3.wav
/usr/bin/arecord: 1: /usr/bin/arecord: Syntax error: word unexpected (expecting ")")
Sorry, I wasn't clear enough.

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
$ 
$ /usr/bin/arecord -t wav -f cd -d 84 /home/randy/Music/chu3.wav
For your earlier post, this is what I get what I run echo $(date "+\%^b\%d\%y").wav in bash and sh
Code:
~ $ echo $(date "+\%^b\%d\%y").wav
\JAN\07\15.wav
~ $ sh
$ echo $(date "+\%^b\%d\%y").wav
.wav
 
Old 01-07-2015, 01:57 PM   #14
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by rmcellig View Post
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
Run from the Terminal:
Code:
/usr/bin/arecord -t wav -f cd -d 44 /home/randy/Music/test.wav
You may be having a user access conflict. If you are not logged in, you don't own access to the audio.

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.
 
Old 01-07-2015, 10:07 PM   #15
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perplexing sound problem, maybe flash related? Z038 Linux - General 2 11-11-2009 10:52 PM
Perplexing Joystick Problem jayfree Linux - Hardware 1 10-28-2009 01:31 AM
Perplexing problem mohitanchlia Linux - Software 1 08-04-2009 10:55 AM
Perplexing Problem eqisow Linux - General 7 08-17-2005 12:02 PM
Perplexing wireless routing problem Gerr Linux - Wireless Networking 8 03-30-2004 08:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration