table of contents
SLEEPENH(1) | General Commands Manual | SLEEPENH(1) |
NAME¶
sleepenh - an enhanced sleep program.SYNOPSIS¶
sleepenh [initial-time] sleep-timeDESCRIPTION¶
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.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).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 |