|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
My requirement is to start a program at a future time x and stop it at time x+delta. Can someone tell me how I can do it using shell scripts. TIA, R C |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
R C V wrote:
> > My requirement is to start a program at a future time x and stop > it at time x+delta. Can someone tell me how I can do it > using shell scripts. if delta is >= 1 Minute: man cron -- Best regards | Monica Lewinsky's X-Boyfriend's Cyrus | Wife for President |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Possibly the cron is a better solution, but I like the shell ![]() set -x # for debug only #x='2008/03/28 22:40:28' x=`date -d+20sec "+%Y/%m/%d %H:%M:%S"` delta='0 day 0 hour 0 min 15 sec' x=`date -d "$x" +%s` delta=`date -d "1969-12-30 21:00:00 +$delta" +%s` echo x=$x\s delta=$delta\s read -t $(($x-`date +%s`)) </dev/tty59 date;echo -e '\astart program &' read -t $delta </dev/tty59 date;echo -e '\akill signal program' >R C V wrote: > My requirement is to start a program at a future time x and stop > it at time x+delta. Can someone tell me how I can do it > using shell scripts. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Mar 18, 1:58 pm, R C V <rss...@gmail.com> wrote:
> Hi, > My requirement is to start a program at a future time x and stop > it at time x+delta. Can someone tell me how I can do it > using shell scripts. > > TIA, > R C Cron s me schedule it at a future time , but does not let me kill it after a specified "duration".. Can someone throw some more light ? |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
In you script, start a subshell to kill it.
Example: (read -t $delta </dev/tty59;kill SIG $$)& At your choice, read or sleep... R C V wrote: > On Mar 18, 1:58 pm, R C V <rss...@gmail.com> wrote: > > Hi, > > My requirement is to start a program at a future time x and stop > > it at time x+delta. Can someone tell me how I can do it > > using shell scripts. > > > > TIA, > > R C > > > Cron s me schedule it at a future time , but does not let me kill > it after > a specified "duration".. Can someone throw some more light ? |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 2008-03-19, R C V wrote:
> On Mar 18, 1:58 pm, R C V <rss...@gmail.com> wrote: >> Hi, >> My requirement is to start a program at a future time x and stop >> it at time x+delta. Can someone tell me how I can do it >> using shell scripts. > > Cron s me schedule it at a future time , but does not let me kill > it after > a specified "duration".. Can someone throw some more light ? Put the check into the script: { # put the script here : ... } & sleep $delta kill $! -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Tue, 18 Mar 2008 17:10:09 -0700, R C V wrote:
> On Mar 18, 1:58 pm, R C V <rss...@gmail.com> wrote: >> Hi, >> My requirement is to start a program at a future time x and stop >> it at time x+delta. Can someone tell me how I can do it using shell >> scripts. >> >> TIA, >> R C > > > Cron s me schedule it at a future time , but does not let me kill it > after > a specified "duration".. Can someone throw some more light ? http://stromberg.dnsalias.org/~strombrg/maxtime.html |
|
![]() |
| Outils de la discussion | |
|
|