how to code a timer loop in a sh script

mfv mfv at bway.net
Mon Nov 6 19:15:41 UTC 2017


> On Mon, 2017-11-06 at 12:24 Tim Daneliuk <tundra at tundraware.com>
> wrote:
>
>On 11/06/2017 12:21 PM, Ernie Luzar wrote:
>> Trying to write a sh script that will run continually and every 10
>> minutes issue a group of commands. Been trying to use the wait
>> command and the while loop command to achieve the desired effect
>> with no joy. Would like an example of a wait loop code to see how
>> its done.
>> 
>> Thanks for any help.
>> _______________________________________________
>> freebsd-questions at freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to
>> "freebsd-questions-unsubscribe at freebsd.org"  
>
>while [ 1 = 1 ]
>do
>   command
>   command
>   ...
>   sleep 600
>done
>

Hello,

It is also possible to use the ":" command as part of the loop.  Thus,

while :
do
   command
   command
   ...
   sleep 600
done

In other words replace "[ 1 = 1 ]" with a single colon ":".

According to "man 1 sh":

     :            A null command that returns a 0 (true) exit value.

Cheers ...

Marek


More information about the freebsd-questions mailing list