Launch recording from PHP

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm working on a small web-script that would allow me to remotely setup  
recordings to my tv-tuner (on my linux box). The idea is simple, but I'm  
unsure how to accomplish it.

The idea: Using PHP generated www-page user could set mencoder to start  
recording at some specified time. The command is put to the crontab  
using linux "at" command.

Problem is that I don't think it is an good idea to grant www-data user  
(that runs apache/php process) to tinker with audio and video hardware.  
Even worse idea is to grant www-user rights to use "at" command.

I use mysql database to store some recording information and thus I  
could use mysql TRIGGER-functionality to put the recording command to  
crontab, however at that case I should give mysql user video and audio  
priviledges. Again - not so good.

Can anybody give an good advice how to do this wihtout dangering system  

Jussi Rasku

Re: Launch recording from PHP

Quoted text here. Click to load it

Set up a cron job to periodically run a script that will perform the
action you want. The script should check the database for any work to
do at this time, and if there is nothing to do then it just exits.
Adjust the frequency of the cron job so that it matches the accuracy of
recording start time you require - say, every 5 minutes.

This way, no-one else has to be given permissions to add "at" commands
or mess with the hardware.


Re: Launch recording from PHP

Can't you use some in-between storage?
Like: the webpage puts a record in the database,
Another process regularly checks for new entries in the database and  
acts if it finds a new one.
Using this "token passing", the web process needs no access except to  
the database and the tv "listener" needs no web access.

Best regards

Jussi Rasku wrote:
Quoted text here. Click to load it

Re: Launch recording from PHP

Dikkie Dik wrote:
Quoted text here. Click to load it

Thanks for the tip, altough I don't like the idea of polling. However it  
seems its the easiest way to do this nicely.

Perhaps I will do some kind of semaphore file the polling script checks  
and the php script sets. That way there is no need for the polling sript  
to handle the database everytime (shouldn't take too much system resources).


Site Timeline