SLEEPENH(1)

๐Ÿ“ฆ
version 1.8 ยท 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’ค SLEEPENH(1) โ€” user commands, but make it a whole vibe ๐Ÿ’ค

okay bestie, sit down, hydrate, because we're talking about sleepenh โ€” the enhanced sleep program โ€” and honestly? it's giving main character energy in the shell-scripting world. ๐Ÿซถ


โœจ NAME โœจ

sleepenh โ€” an enhanced sleep program ๐ŸŒ™


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

sleepenh [[--warp|-w] INITIALTIME] TIMETOSLEEP

๐Ÿ’… DESCRIPTION ๐Ÿ’…

so here's the tea, bestie: sleepenh is the program you reach for when you need to run stuff periodically inside a shell script. ๐Ÿ”

and like โ€” important โ€” it was not designed to be accurate for one single sleep. it's designed to be accurate across a sequence of consecutive sleeps. that's the whole point, that's the moment, no cap. โœจ

after it runs successfully, it prints to stdout the timestamp it finished running. and that value? you feed it back in as INITIALTIME to the next sleepenh call. it's a little relay race and it's iconic. ๐Ÿƒโ™€๏ธ๐Ÿ’จ


๐ŸŒธ OPTIONS ๐ŸŒธ

  • -h, --help โ€” display this help and exit ๐Ÿซก
  • -w, --warp โ€” warp the resulting timestamp, for when there's no need to sleep. an immediately following call of sleepenh with the resulting TIMESTAMP would most probably result in a real sleep. ๐ŸŒ€
  • -V, --version โ€” output version information and exit ๐Ÿ‘‘

๐Ÿฆ‹ ARGUMENTS ๐Ÿฆ‹

  • TIMETOSLEEP โ€” a real number in seconds, with microseconds resolution. so like, 1 minute, 20 seconds and 123456 microseconds would be 80.123456. math but make it cute. ๐Ÿงฎโœจ
  • INITIALTIME โ€” also a real number in seconds, with microseconds resolution. heads up though: this number is system dependent. on GNU/Linux systems it's the number of seconds since midnight 1970-01-01 GMT. โณ
โš ๏ธ do not try to get a good value of INITIALTIME yourself, bestie. just use the value supplied by a previous execution of sleepenh. trust the process. ๐Ÿ™

if you don't specify INITIALTIME, it's assumed to be the current time. easy. ๐ŸŒˆ


๐Ÿ’€ EXIT STATUS ๐Ÿ’€

an exit status greater or equal to 10 means failure. here's the known lineup:

  • 0 โ€” Success. ๐ŸŽ‰
  • 1 โ€” Success. There was no need to sleep. (this means that INITIALTIME + TIMETOSLEEP 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, fr fr:

#!/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

and boom, you're a time lord now. โฐ๐Ÿ‘‘


๐Ÿ˜ญ BUGS ๐Ÿ˜ญ

it is not accurate for a single sleep. short TIMETOSLEEPs will also not be accurate. she's a group-project girlie, not a solo act. ๐Ÿ’”


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

date(1), sleep(1).


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

this manual page was written by Pedro Zorzenon Neto. ๐Ÿ’œ


and that's the whole page, bestie โ€” this version of the sleepenh manual is from 2024-12-09, and it's filed under the sleepenh name in the user commands section. sleep tight, literally. ๐Ÿ’คโœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from