Hello

I have a script which records from the tv card on my linux computer. I like to create a webinterface to schedule recordings.

I need to create a cron-job from php.

I think something with sudo or modify directly the crontab file is possible...

Has anybody already done something like this or any idea to get this working?

Thanks in advance

Sam

    You have 2 options really and both are insecure. You could run apache as root so it has write access to the files or you could chmod the files/directories so the user the web server is running as has write access to it. Both of these options leave you in a very vulnerable situation where an attacker can gain root access to your box instead of just the user "nobody". If you are running this on a box not connected to the net, it will be ok. In your httpd.conf you should edit the User and Group to root.

    Hope this helps.

    sglane

      I've kind of run into this problem before. I find for one time job scheduling, the "at" command had worked well for me.

      Umm... Another approach might be to schedule a cron job to run a script every so often to see if a request for a cron job update has been made. If so, check what the request was and update crontab. Depending on your needs, maybe checking every hour or every 15 minutes might work. This requires a little creativity on your part.

      Another idea I had involved socket servers and having one listen for new "job" requests and then have the socket server update crontab. But I have a feeling you open up another can of worms with this approach if you're not careful.

        Hello

        Thanks for your answers

        The at command sounds also good to me.
        How did you call it from PHP? (sudo ?)

        Thanks and Greets

        Sam

          Originally posted by AstroTeg
          Umm... Another approach might be to schedule a cron job to run a script every so often to see if a request for a cron job update has been made. If so, check what the request was and update crontab. Depending on your needs, maybe checking every hour or every 15 minutes might work. This requires a little creativity on your part.

          Yes, but not too much. Using the PHP CLI, it's quite possible to do such things. And, if you want a web frontend to it that's possible, too.

          1. A web form and handler script reads the existing crontab and then writes the modified version to a 777'ed directory, such as the UNIX /tmp.

          2. Root's crontab runs a script periodically to check for the existence of that file, and copy it to the cron daemon's directory.

          No biggie, just a bit of time coding. It's finding the time that's the problem, right? That's why he's not gonna be there when the show is on the tube, anyway!!! 😃

            Write a Reply...