[SOLVED] Script for auto-audio-recording - Crontab
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
2. Pipe it into the 'lame' encoder (see man page for lame) to get mp3 format,
3. Wrap it up with 'timeout' (see man page for timeout) to set recording period,
4. Make it all into a shell script and enter it in 'crontab' (see man page for crontab) to run at scheduled times. Instead of crontab you can also use 'at' (see man page for at).
Sorry that's not exactly a script. Maybe someone else has something closer to a final product.
I have a short script that I use to record vinyl albums for further processing with gwc. In order to nice the recording I have to run it as root so I added an entry to sudoers (and another to change ownership). Here's the script, you can build on it:
I guess the Sound HOWTO is a bit out of date, and 'arecord' is the right thing if you are using ALSA. I see it also has a duration switch (so 'timeout' not needed) and can write to standard output (as -). So I guess the basic recording command could be something like
except the name of the output file would have to change to stop overwriting. I don't understand sound recording with ALSA, so I have no idea what options would be needed in this case.
How would crontab know to place the original recording in ~/recordings ? Looks like F, H and M are assigned variables. are they lame specific, cron specific or can they be use systemwide without setting them first and getting ... well, what output, really? I'm interested in the script and at the same time trying to learn something about scripting etc.
I read something about command substitution , but so far I'd only seen it after a variable had been set, like
read mn
echo $mn
Now I understand the variable you're calling is date which actually is a program which has a number of possible parametres.
Thanks for the explanation. (Still so much to learn)
To see what the date string would look like, try running the command in the brackets - you could tailor it as you like of course.
cron would simply run the command, in this case it's the lame program that puts the output in ~/recordings as specified. If you set up the crontab for your user acount then it would run the commands as you, so it will use your home directory.
OK. Probably didn't read the command carefully enough. You pipe the input straight to lame - so lame doesn't read from a file in ~/recordings, but only places its output there. Think I'm beginning to understand.
Bringing up the subject again after a long time. I need to make crontab start a new recording every 2 hours of every day of every month of every year. But each time a file is done it's supposed to save the recorded file with it's date and time: i.e. 06-11-23-00-02.wav
How would I do this?
I need to make cronjob start a new recording every 2 hours of every day of every month of every year. But each time a file is done it's supposed to save the recorded file with it's date and time: i.e.
Code:
11-23-06_1400.wav
and the next one would be
Code:
11-23-06_1600.wav
and so on.
How would I do this? I'm guessing I'll need a script for this, or a couple of them. But I'm not very proficient yet in writing them. So you'll have to help me.
The hard part would be to stop the previous recording and make it save
the file with a given name. And the names suck, you can't sort those
chronologically, you should have YYYY-MM-DD-time.wav, not MM-DD-YYYY
(which is the most stupid convention anyone ever dreamt up :}).
Which software are you using for recording, anyway?
I think the best thing to do would be to check out the man page for crontab, as it instructs you on how to set up the crontab entry. Assuming that Ubuntu uses the same cron Slackware, the entry would be something like:
The important parts are the second parameter */2 which says to run it every 2 hours (on the even hours), and the ampersand which says to run it in the background (or else it might not start a new recording if the previous one hasn't quite finished yet and the soundcard is locked).
To be honest I've never really set up a crontab entry like this before, so caveat emptor.
I think the best thing to do would be to check out the man page for crontab, as it instructs you on how to set up the crontab entry. Assuming that Ubuntu uses the same cron Slackware, the entry would be something like:
The important parts are the second parameter */2 which says to run it every 2 hours (on the even hours), and the ampersand which says to run it in the background (or else it might not start a new recording if the previous one hasn't quite finished yet and the soundcard is locked).
To be honest I've never really set up a crontab entry like this before, so caveat emptor.
Thanks, I'll try that. Makes sense. I saw something like this on another site, but it was different. This makes sense.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.