|
|
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:
$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.)(while true
>do
>who >> who_report
>sleep 3600
>done)&
$
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'').