how to schedule a command to run for specified length of time - Mandriva

This is a discussion on how to schedule a command to run for specified length of time - Mandriva ; I am trying to capture video with specific start and stop times. What I'd like to do is begin recording at time, which I could presumably do with "at" or "cron". But how do I have the command stop at ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: how to schedule a command to run for specified length of time

  1. how to schedule a command to run for specified length of time

    I am trying to capture video with specific start and stop times.
    What I'd like to do is begin recording at time, which I could
    presumably do with "at" or "cron". But how do I have the command stop
    at a later time? I could probably write a simple script to do a "ps",
    grep for the PID and kill it. However, I'm sure there is a more
    elegant way to accomplish this already out there.

    I'm sure I've seen a similar post to this one in the last year here,
    but haven't been able to find it. I've spent the last hour googling
    for the answer but my search queries came up with too many unrelated
    topics.

    Thanks in advance.
    -Greg


  2. Re: how to schedule a command to run for specified length of time

    On Sat, 21 Jul 2007 19:04:30 -0400, Greg wrote:

    > I am trying to capture video with specific start and stop times.
    > What I'd like to do is begin recording at time, which I could
    > presumably do with "at" or "cron". But how do I have the command stop
    > at a later time? I could probably write a simple script to do a "ps",
    > grep for the PID and kill it. However, I'm sure there is a more
    > elegant way to accomplish this already out there.


    In the script you start with cron, or at, I'd use an & at the end
    of the command starting the capturecmd, to put it in the background,
    and then, in the script, run
    echo "killall capturecmd"|at now + 1 hours

    That way you don't have to bother with process ids.

    You may want to experiment with which signal to use, to ensure the
    files get closed properly. For example, SIGQUIT (3), may be better
    then SIGTERM (15), which is the default. I haven't experimented with
    this, so I'm not sure.

    Regards, Dave Hodgins

    --
    Change nomail.afraid.org to ody.ca to reply by email.
    (nomail.afraid.org has been set up specifically for
    use in usenet. Feel free to use it yourself.)

+ Reply to Thread