Link to home
Start Free TrialLog in
Avatar of mrcool4444
mrcool4444

asked on

Linux timer (sleep, delay, pause, etc) function

I have a set of processes that I want done in an infinate loop.  Obviously if I put them into an actual loop, I will get 100% cpu usage (not acceptable).  A funtion that stoppes the loops for about a minute should (I am hoping) solve this problem.  The code must work in linux.

Example of what I need:

      do
      {
           reload();
           bandwith();
           fileload();
           filewrite();
     }
     while (FOREVER);

But, the above needs to be done every minute in a loop.  So I think something like do { timer(1minutes) } while (FOREVER) would solve this problem.
ASKER CERTIFIED SOLUTION
Avatar of akshayxx
akshayxx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrcool4444
mrcool4444

ASKER

Hmm, man 2 sleep gives me: No entry for sleep in section 2 of the manual

I did manage to find that sleep() was located in unistd.h.

Everything works great now (except for the man page).

Thanks!
welcome .. btw u could have tried
man sleep
man 3 sleep
actually man sleep will give u the manual page for command line 'sleep'
usually library functions' man pages are in 2nd 3rd sections

any ways good to know it worked for u
man 3 sleep did it :)