The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sleep working meetbhattu UNIX for Advanced & Expert Users 2 10-29-2007 01:05 PM
Sleep Command Glove Shell Programming and Scripting 1 10-03-2007 02:02 AM
Sleep() not working enuenu High Level Programming 2 06-01-2007 10:01 PM
Sleep under one second Scoogie Shell Programming and Scripting 5 08-14-2002 05:10 AM
sleep Anna UNIX for Dummies Questions & Answers 5 07-10-2001 08:52 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-23-2005
Registered User
 

Join Date: Aug 2005
Location: Sweden
Posts: 5
Stumble this Post!
Sleep less than 1 second

Does anyone know a way to sleep less than 1 second?
Sometimes when I write scripts that iterates a loop many times it would be
nice to slow things down, but sometimes 1 second is too much.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-23-2005
Registered User
 

Join Date: Feb 2004
Posts: 91
Stumble this Post!
Quote:
Originally Posted by bjorno
Does anyone know a way to sleep less than 1 second?
Sometimes when I write scripts that iterates a loop many times it would be
nice to slow things down, but sometimes 1 second is too much.
If your system has "usleep" this allows you to sleep in increments of milliseconds instead of seconds.
Reply With Quote
  #3 (permalink)  
Old 08-23-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,841
Stumble this Post!
usleep in C code.
Reply With Quote
  #4 (permalink)  
Old 08-23-2005
Registered User
 

Join Date: Aug 2005
Location: Sweden
Posts: 5
Stumble this Post!
I dont have usleep in my system, which is AIX 5.2.
Is there a compiled version of usleep to download. I think I'm not able
to compile it myself.
Reply With Quote
  #5 (permalink)  
Old 08-24-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,443
Stumble this Post!
If you have perl try:

perl -e 'select(undef,undef,undef,.1)'

That .1 means .1 seconds.
Reply With Quote
  #6 (permalink)  
Old 08-24-2005
Registered User
 

Join Date: Aug 2005
Location: Sweden
Posts: 5
Stumble this Post!
Quote:
Originally Posted by Perderabo
If you have perl try:

perl -e 'select(undef,undef,undef,.1)'

That .1 means .1 seconds.
That works. It is hard to meassure the time but it is definitely less than 1 second.

Thanks a lot.
Reply With Quote
  #7 (permalink)  
Old 08-24-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,841
Stumble this Post!
IT's not hard to measure the elapsed time:
Put Perderabo's code in a script, call it usleep.sh
Code:
time usleep.sh
will give you something like this:
Code:
kcsdev:/home/jmcnama> time usleep.sh

real    0m0.18s
user    0m0.03s
sys     0m0.05s
real is the elapsed time.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0