help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] how to set up a repeat check procedure?


From: Jasper Noë
Subject: Re: [Help-bash] how to set up a repeat check procedure?
Date: Thu, 29 Dec 2011 12:55:15 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11



On 29-12-11 08:53, lina wrote:
On Thursday 29,December,2011 03:29 PM, lina wrote:
Hi,

How can I let a script keep on checking whether a file exist or not?

if not, check it again 1 minutes later,
if exist, execute some commands,

I started writing the

#!/bin/sh
file=a.txt

if [ -e $file ]; then
echo "$file exists"
else
sleep 60
## I don't know how to let it back to check,
fi


Thanks with best regards,
The a.txt was the one destined to be generated, but the generation time
won't be know, which might last from 2 mins to 2 hours,

so I wish there is a script there check whether it's generate or not, if
generate, so it can proceed further.

It's a bit dynamic process, sort of .. haha ...

Thanks for your advice,

Best regards,



Generally you make a loop like this:

while true; do

        something

done

In this particular case you could write:

until [ -f $file ]; do

        sleep 60

done

Untested, hth, --Jasper.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]