Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.:
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.
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
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.
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?"
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.
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.
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.
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 >>
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?
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.
/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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.