Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Nov 2017 14:15:30 -0500
From:      mfv <mfv@bway.net>
To:        Tim Daneliuk <tundra@tundraware.com>
Cc:        Ernie Luzar <luzar722@gmail.com>, "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: how to code a timer loop in a sh script
Message-ID:  <20171106141530.22611a51@gecko4>
In-Reply-To: <a2e0064c-2d0a-b1ee-899d-3134c9da5537@tundraware.com>
References:  <5A00A826.2000501@gmail.com> <a2e0064c-2d0a-b1ee-899d-3134c9da5537@tundraware.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> On Mon, 2017-11-06 at 12:24 Tim Daneliuk <tundra@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@freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to
>> "freebsd-questions-unsubscribe@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171106141530.22611a51>