[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: regulating the time a process can run with crontab?



Cool, that's what using at was for. I never knew how to get the process of
a script in to a variable with $!, better than using killall. Is there any
way, to for say,
Read a time as the prompt for some script which is in a variable, use it to
schedule up an at job for start and end this way?
For example:
#!/bin/sh
echo Enter the time to start recording
read START
echo Enter the time to stop recording
read END
echo enter the stream url to be recorded
read URL
echo $URL >/tmp/streamurl
at $START /usr/local/bin/record

Then in /usr/local/bin/record
#!/bin/sh
lynx --source `cat /tmp/streamurl` >path_to_file.mp3
PROC=$!
at $end kill $PROC
One would probably use a date command to insure the file name won't
overwrite the last episode if it's not gone yet, and clean up the temp file
created. The only real problem with it is that if someone put in (halt) in
as a time, your system would go down if this is run by root. No error
checking at all in this, not sure if time is a possible test to make sure a
valid time of day is used.
At 04:55 PM 1/5/02 -0700, you wrote:
>And you might find that the "at" command is better choice
>for timing than "sleep" or cron.  For example:
>
>mpg123 lecture.mp3 &
>SOUNDPROC=$!
>
>at now+2hours << End_of_here_document
># Or: 
># at 9:30pm << End_of_here_document
>kill $SOUNDPROC
>End_of_here_document
>
>On Fri, 4 Jan 2002, James R. Van Zandt wrote:
>
>> One way to limit the duration of a command is to run it in a
>> subprocess (i.e. put the shell command in parentheses) and have the
>> parent kill it.  Here's an example:
>> 
>>   #!/bin/bash
>>   # try to send a string to the synthesizer via four different serial
>>   #ports
>>   for x in 0 1 2 3; do
>>       (DTK_PORT=/dev/ttyS$x
>>       echo "trying $DTK_PORT"
>>       stty sane 9600 raw -echo crtscts <$DTK_PORT &&\
>>       stty -echo                       <$DTK_PORT &&\
>>       stty ixon ixoff                  <$DTK_PORT &&\
>>       echo "this is /dev/t t y s $x" $'\r' >$DTK_PORT )&
>>   # if one of the above commands hangs, kill the process
>>       sleep 2; kill $! >/dev/null 2>&1
>>   done
>
>-- 
>L. C. Robinson
>reply to no_spam+munged_lcr onewest net invalid
>
>People buy MicroShaft for compatibility, but get incompatibility and
>instability instead.  This is award winning "innovation".  Find
>out how MS holds your data hostage with "The *Lens*"; see
>"CyberSnare" at http://www.netaction.org/msoft/cybersnare.html
>
>
>
>_______________________________________________
>Blinux-list mailing list
>Blinux-list redhat com
>https://listman.redhat.com/mailman/listinfo/blinux-list
>
>





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]