DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Controlling processes

Delaying the execution of a process

The sleep(C) command suspends the execution of a command for a number of seconds. For example (sleep 20; date > /dev/tty06) & delays the execution of the date(C) command by 20 seconds.

sleep is useful for spacing out commands:

   $ (while true
   > do
   > who >> who_report
   > sleep 3600
   > done)&
   $
This sequence repeats the who command every 3600 seconds (1 hour), and writes the output to a file called who_report. (This task could also have been carried out using the cron command.)

Using ``>>'' in the sequence causes the output to be appended to the end of who_report. If ``>'' were used instead, the contents of the file would be overwritten each time the who command was run. For an explanation of the while structure, see ``Automating frequent tasks'').


Previous topic: Executing processes at regular intervals

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003