[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.
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.
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'm using sound-recorder
So here is an example including you suggestion. Is it OK?
How exactly do I format the +%y-%m-%d-%k-%M part so it does what I want? Or is it fine in it's current state?
BTW, maybe I schould put the command in a script so that I just have to modify the script if I need the command to change, right?
I'm using sound-recorder
So here is an example including you suggestion. Is it OK?
How exactly do I format the +%y-%m-%d-%k-%M part so it does what I want? Or is it fine in it's current state?
BTW, maybe I schould put the command in a script so that I just have to modify the script if I need the command to change, right?
OK, got it going. Just in case someone wants to know how I did it:
Here is my crontab ( I realize I could make it simpler, i.e: putting */2 by the hour entry, but I wanna be able to set stuff every two hours if I want to)
Quote:
#min hr dom mon dow cmd
* 0 * * * sh /home/server/.scripts/aircheck.sh
* 2 * * * sh /home/server/.scripts/aircheck.sh
* 4 * * * sh /home/server/.scripts/aircheck.sh
* 6 * * * sh /home/server/.scripts/aircheck.sh
* 8 * * * sh /home/server/.scripts/aircheck.sh
* 10 * * * sh /home/server/.scripts/aircheck.sh
* 12 * * * sh /home/server/.scripts/aircheck.sh
* 14 * * * sh /home/server/.scripts/aircheck.sh
* 16 * * * sh /home/server/.scripts/aircheck.sh
* 18 * * * sh /home/server/.scripts/aircheck.sh
* 20 * * * sh /home/server/.scripts/aircheck.sh
* 22 * * * sh /home/server/.scripts/aircheck.sh
OK, I'm having trouble. WHen cron starts on the hour, it records fine, but after arrounf 5 min. it stops, terminating the script. Any idea what I'm doing wrong?
crontab -l
Quote:
# m hr dom mon dow command
0 */1 * * * sh /home/server/.scripts/cron_job
Nov 25 09:01:01 ubuntu /USR/SBIN/CRON[23238]: (server) CMD (sh /home/server/.scripts/cron_job)
Nov 25 09:01:01 ubuntu /USR/SBIN/CRON[23235]: (server) MAIL (mailed 119 bytes of output but got status 0x0001 )
Nov 25 09:08:11 192.168.0.248 -- MARK --
Try explicitly back-grounding the script? I've never seen cron terminating
any of my (even longer-running) scripts after a time. Does your recording
software have some flag for producing debug-output?
Till now, the script always produced a 6.8MB file and terminated.
I tried running the script manually and it worked the way it's supposed to. Then I re-read this whole thread and thought that maybe I schould put in the number of seconds it was supposed to record instead of mins. into the script. Now it records double the time and stops again at double the size.
BTW, there is no option for debug output in sound-recorder.
BTW 2, I tried arecord but it always gives me a error:
Quote:
server@ubuntu:~$ arecord -D /dev/dsp0
ALSA lib pcm.c:2143snd_pcm_open_noupdate) Unknown PCM /dev/dsp0
arecord: main:547: audio open error: No such file or directory
Again, just a small detail:
*/1 for the hour setting doesn't make much sense. Replace it by *, just to be sure.
Think of the "/n" operator as "any value that is divisible by n". Since all values are divisible by 1,
/1 can always be omitted. The 0 for the minutes will make sure it runs only once per hour.
Your problem most likely isn't caused by this, though.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.