Operating System - HP-UX
1834434 Members
2337 Online
110067 Solutions
New Discussion

Re: Update every 5 seconds with a 'system' call

 
Amber_1
Occasional Contributor

Update every 5 seconds with a 'system' call

How would you perform a 'system' call every five seconds?

Similar to the function of top, which automatically updates.
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor

Re: Update every 5 seconds with a 'system' call

Hi Amber:

As a generalized example in shell syntax:

while true
do
date
sleep 5
done

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: Update every 5 seconds with a 'system' call

Hi Amber:

Since you said system(), I'm assuming you meant C:

#define DELAY
#define TRUE (1)

int cc = 0;
while (TRUE && cc == 0)
{
cc = system("my_command");
(void) sleep((unsigned) DELAY);
}

Regards, Clay
If it ain't broke, I can fix that.