[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: script timer



The problem is with the exec. When you call exec the control is
transferred to that program with same pid and is never returned back. 
Use fork() and exec in the child . Let the parent sleep and remain in the
infinite loop.
On Thu, 5 Aug 1999, Chien-Lung Wu wrote:

> 
> Hi, 
> 
> Can any one help me out? I have a small program, which should be execute
> every 5 sec. I have a simple script as following:
> 
> 
> #!/bin/sh
> 
> while [ "forever" ]
> do
> 
> 	exec myfile
> 
> 	sleep 5s
> done
> 
> 
> It seem just can execute one times. How can I set this timer on and run
> myfile in every 5 sec.
> 
> 
> 
> 
> I also try to write a C program to approach this prolem.
> 
> My C code is as following:
> 
> #include <stdio.h>
> #include <unistd.h>
> 
> void man (void) {
> 
> 	while (1)
> 	{
> 
> 		execl ("/home/myfile", "myfile", NULL);
> 		/* myfile have been compiled to be executable and put on
> 		   /home/ */
> 
> 		sleep(5);
> 	}
> }
> 
> In the C code case, it still just executes one time?
> 
> 
> Can any help me out?
> 
> Thanks,
> 
> C.L.
> 
> 
> ****************************************************************************
> Chien-Lung Wu						cwu4@xxxxxxxxxxxx
> Graduate Student of ECE 				(O) 919-513-1894
> at North Carolina State University			(H) 919-233-6724
> ****************************************************************************
> 
> 
> --------------------------------------------------------------------
> For more information on Linux in India visit http://www.linux-india.org/
> The Linux India mailing list does not accept postings in HTML format.
> 

- --------------------------------------------------------------------
For more information on Linux in India visit http://www.linux-india.org/
The Linux India mailing list does not accept postings in HTML format.

------------------------------