I have recently had experience of recording using crontab, took a while to get it working.
The problem with crontab apparently is it runs in some sort of separate user space so even though it maybe running as your userid (as opposed to root) it does not interact with your profile, so to get round this I have to get crontab to use "at" to run my commands, but there is a catch in that you can't get "at" to run commands directly so you point it at a file with the commands in you want to run.
I start VLC command line from crontab which works until you try and get it to display on the screen and the reason I wanted to do this was because I have a wireless speaker and the dongle needs to be detected and get output from pulse audio which is user profile based, so I figured out how to get my server to start VLC on the display and record and forward on using TCP. So I auto-login the user at boot time and when crontab starts "at" which runs he script then I can see the VLC app on the desktop and the wireless speaker works and it records the stream and I can pick up the forwarded stream on other PCs with VLC player (or another).
So this is how I did it
(I use uuid to create unique filenames, get it from apt)
1) in ~/radio/scripts I created a script called "run_at.sh" which puts the command string pased to it into a file which "at" then uses, this is it
Code:
#!/bin/sh
FILEUUID=`uuid`
echo "AT to run: $*"
echo $* >/tmp/at_$FILEUUID
sleep 1
at now +0 minutes -f /tmp/at_$FILEUUID
sleep 1
rm /tmp/at_$FILEUUID
2) I created other scripts for what I want to do, for example I called one "live_play_stream_rec.sh", I have to use DISPLAY=:0.0 to get it to display on the desktop, so this may look like this
Code:
#!/bin/sh
DISPLAY=:0.0 timeout 1800 vlc --quiet --no-video --no-qt-error-dialogs --live-caching 4000 --sout-keep --sout-file-append --sout "#duplicate{dst=display,dst='transcode{aenc=ffmpeg,acodec=mp3,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=file,mux=dummy,dst=PROGFILE.mp3},dst=std{access=http,mux=dummy,dst=192.168.1.1:8080}}'}" PLAYLIST.pls
3) in my crontab I put
Code:
30 18 * * 1-5 radio/scripts/run_at.sh radio/scripts/live_play_stream_rec.sh
so at 18:30 Mon-Fri it starts VLC, with the radio stream in PLAYLIST.pls which I can then pick up around he house on other PCs and my wireless speaker in the bathroom, and it records the stream to PROGFILE.mp3 and quits after 30 minutes.
Hope this helps
GB
Btw I found all the complicated VLC stuff on the VLC wiki
Bookmarks