Help needed for Sleep (File watcher)

Hi All,

I have a requirement, where I need to check for file. If file is not available then wait for 5 minutes and if it still not available, fail the process. It should check every one minute.

If File available in between, should start remaining process. Now my problem is, I have both part ready. But not able to understand where to put script logic, if file is available.

Ex: Wait for file, for 5 minutes, check every one minute

#!/bin/ksh
let tw=0
let num=60

while [ ! -f /home/aa.txt ]; do
sleep 60
tw=`expr ${tw} + ${num}`
if [ ${tw} -eq 300 ]
then
echo "Time exceed 5 minutes"
exit 1;
else
echo "Waiting for file, wait time exceeds ${tw}"
fi
done

Now, if file aa.txt is available at beginning or in between above , then I need to start working on it. I do not know where to keep that portion. Can somebody help me?

---------- Post updated at 09:09 PM ---------- Previous update was at 08:59 PM ----------

Sorry, I found solution. I have posted solution for same in 2008. :slight_smile:

Apologize for this.