Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sleepenh(1) [debian man page]

SLEEPENH(1)						      General Commands Manual						       SLEEPENH(1)

NAME
sleepenh - an enhanced sleep program. SYNOPSIS
sleepenh [initial-time] sleep-time DESCRIPTION
sleepenh is a program that can be used when there is a need to execute some functions periodically in a shell script. It was not designed to be accurate for a single sleep, but to be accurate in a sequence of consecutive sleeps. After a successful execution, it returns to stdout the timestamp it finished running, that can be used as initial-time to a successive exe- cution of sleepenh. OPTIONS
There are no command line options. Run it without any option to get a brief help and version. ARGUMENTS
sleep-time is a real number in seconds, with microseconds resolution (1 minute, 20 seconds and 123456 microseconds would be 80.123456). initial-time is a real number in seconds, with microseconds resolution. This number is system dependent. In GNU/Linux systems, it is the number of seconds since midnight 1970-01-01 GMT. Do not try to get a good value of initial-time. Use the value supplied by a previous exe- cution of sleepenh. If you don't specify initial-time, it is assumed the current-time. EXIT STATUS
An exit status greater or equal to 10 means failure. Known exit status: 0 Success. 1 Success. There was no need to sleep. (means that initial-time + sleep-time was greater than current-time). 10 Failure. Missing command line arguments. 11 Failure. Did not receive SIGALRM. 12 Failure. Argument is not a number. 13 Failure. System error, could not get current time. USAGE EXAMPLE
Suppose you need to send the char 'A' to the serial port ttyS0 every 4 seconds. This will do that: #!/bin/sh TIMESTAMP=`sleepenh 0` while true; do # send the byte to ttyS0 echo -n "A" > /dev/ttyS0; # just print a nice message on screen echo -n "I sent 'A' to ttyS0, time now is "; sleepenh 0; # wait the required time TIMESTAMP=`sleepenh $TIMESTAMP 4.0`; done HINT
This program can be used to get the current time. Just execute: sleepenh 0 BUGS
It is not accurate for a single sleep. Short sleep-times will also not be accurate. SEE ALSO
date(1), sleep(1). AUTHOR
This manual page was written by Pedro Zorzenon Neto. 2008/04/20 SLEEPENH(1)

Check Out this Related Man Page

SLEEP(1)						    BSD General Commands Manual 						  SLEEP(1)

NAME
sleep -- suspend execution for an interval of time SYNOPSIS
sleep seconds DESCRIPTION
The sleep command suspends execution for a minimum of seconds. If the sleep command receives a signal, it takes the standard action. IMPLEMENTATION NOTES
The SIGALRM signal is not handled specially by this implementation. The sleep command will accept and honor a non-integer number of specified seconds (with a '.' character as a decimal point). This is a non- portable extension, and its use will nearly guarantee that a shell script will not execute properly on another system. EXIT STATUS
The sleep utility exits 0 on success, and >0 if an error occurs. EXAMPLES
To schedule the execution of a command for x number seconds later (with csh(1)): (sleep 1800; sh command_file >& errors)& This incantation would wait a half hour before running the script command_file. (See the at(1) utility.) To reiteratively run a command (with the csh(1)): while (1) if (! -r zzz.rawdata) then sleep 300 else foreach i (`ls *.rawdata`) sleep 70 awk -f collapse_data $i >> results end break endif end The scenario for a script such as this might be: a program currently running is taking longer than expected to process a series of files, and it would be nice to have another program start processing the files created by the first program as soon as it is finished (when zzz.rawdata is created). The script checks every five minutes for the file zzz.rawdata, when the file is found, then another portion processing is done courteously by sleeping for 70 seconds in between each awk job. SEE ALSO
nanosleep(2), sleep(3) STANDARDS
The sleep command is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. HISTORY
A sleep command appeared in Version 4 AT&T UNIX. BSD
April 18, 1994 BSD
Man Page