Script check for file, alert if not there, and continue checking until file arrives

All,
Is there a way to keep checking for a file over and over again in the same script for an interval of time?

Ie

If [no file] {
mail -user
continue checking until file arrives
file arrives
tasks
exit

I don't want the script to run each time and email the user each time a file isn't there. So, I want it to continue checking the file until it arrives and only exit when the file shows up.

To check for file in a loop you can do this:

until [ -f "myfilename" ]
do
sleep 30 ##set it so that does not add load on your system
done

Rest logic you can add I guess.

Thanks sir, I think that is what I was looking for.

So, if I only wanted it to mail on the first iteration is that possible? The sleep is that in seconds?

I also want to be able to send the file arrives. So, that will execute until the file arrives or won't execute until the file arrives?

I think i have my logic:

if [file in dir]
send file
exit
else{
mail users
until (file in dir)
{ send file
}
}

I guess do not put it into iteration, it can be done this way:

[ -f "myfilename" ] || mailx ...

sleep is in seconds. but still can refer your box manpage for detail.

The loop will execute until the file arrives.

We receive a FTP everyday at a certain time in the morning. I want to write a script that would send email notification to all stakeholders, if the file has not arrived on any particular day.

I am new to UNIX and apart from the basic commands know very little about scripting. Can you please help me with this script and explain it as well so I could understand and do it on my own the next time such a task comes up.

Thanks a ton in advance.

Regards