LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   scheduling trouble on ubuntu server 10.10 (https://www.linuxquestions.org/questions/linux-software-2/scheduling-trouble-on-ubuntu-server-10-10-a-883901/)

samhill5215 06-01-2011 04:31 AM

scheduling trouble on ubuntu server 10.10
 
I'm running Ubuntu 10.10 server with no graphics and would like to record video from my capture card. I can do that just fine with "sudo cat /dev/video0 > mycapture.mpg" but run into trouble when I include it in a script such as:

at 12pm << EoF
cat /dev/video > mycapture.mpg &
sleep 10
kill \$!
EoF

Running the script places the job in the at queue but no file is ever created and the job never terminates. It must be done explicitly with atrm. Thinking it was a permission problem I prefixed my script command with sudo to get around the fact that /dev/video0 is owned by root and changed the owner of /dev/video0 to my user name. Neither worked.

Not quite sure what's happening or where to look. Any help would be more than appreciated.

spankbot 06-01-2011 04:12 PM

Does the file "mycapture.mpg" already exist? If so you may be running into the "no clobber" shell feature. You could try turning noclobber off, or, have the name of your mpg file be unique each time the script is run...

Code:

cat /dev/video > mycapture-`date +%Y%m%d`.mpg &
The date command by itself simply prints out the date in the form YYYYmmdd. You can add a minute and second to that if your command runs more than once a day.

So
Code:

date +%Y%m%d
outputs...
Code:

20110601

samhill5215 06-08-2011 04:43 AM

Thanks for that spankbot. Actually, and I'm not sure why, using webmin's scheduled commands module fixed my problem. The strange thing is that webmin also uses AT for scheduling but since I'm running them as root I suspect the problem was tied to permissions. Isn't pretty much everything in linux so? Anyway the commands are:

v4l2-ctl -i 2
cat /dev/video0 > /media/recordings/<name-your-file>.mpg &
CAT_PID=$!
sleep <time-to-record>m
kill $CAT_PID


All times are GMT -5. The time now is 07:52 PM.