![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to copy and repeat | falcondown01 | Shell Programming and Scripting | 4 | 09-07-2007 09:15 PM |
| Search for string and display those NOT found | John Rihn | Shell Programming and Scripting | 17 | 05-22-2007 09:22 AM |
| Get line1 and line4 in a repeat pattern file | bobo | UNIX for Dummies Questions & Answers | 3 | 10-25-2006 12:11 PM |
| Recursive Search and replace only when found string | umen | Shell Programming and Scripting | 1 | 05-07-2006 02:20 PM |
| Repeat Commands | dereckbc | UNIX for Dummies Questions & Answers | 6 | 01-04-2005 11:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
search for a file, if not found sleep and repeat it for 3 hrs
Hi,
Can someone help me with this script .... I need a ksh script, which will search for a specific file in a directory, if file not found sleep for 10 mins and search again, if still not found sleep again for 10 mins and so on .... it should search for that file for 3 hours and if that file is still not found, then it should send a e-mail. Appriciate your help with this ... Thanks, Sant |
|
||||
|
This won't be a complete answer, as ksh really isn't my thing; however, I would base a quick and dirty script of this kind you describe on the fact that there are 18 10-minute periods in 3 hours. So, something like this might be a reasonable framework: Code:
integer n=0
while ((n <= 18));
do
if [[ -e filename ]]
then
integer n=19
else
if [[ n = 18 ]]
Send your mail with whatever command you need....
else
sleep 600
fi
fi
n++
done
Anyway, that's the idea... it'll require lots of work, and I would be stunned if it ran without significant alteration. Some of it probably isn't even valid ksh. Hopefully it gives you a starting point, though. |
|
||||
|
here is the script i tried ..
Here is the script i tried ...
#! /usr/bin/ksh File="abc.txt" if [ -f $DIR/$File ] then echo "File Found" break else i = 0 echo "File Not Found! Wait for 10 mins and try searching again!" sleep 10m i = i + 10 if [i > 120] then echo "Alert!! File not found for 2 hrs!!" | mailx -s "File not found" abc@abc.com break fi fi |
|
||||
|
Thanks friends
Thanks for all ur help ... here goes the final script ... Code:
while (( $i <= 60 ))
do
if [ -f $File ]
then
echo "File Found"
break
else
sleep 10
i=`expr $i + 10`
if [ $i -gt 60 ]
then
echo "ALERT!!" | mailx -s "ALERT!!" ${ID}
else
sleep 1
fi
fi
done
|
![]() |
| Bookmarks |
| Tags |
| search file for 3 hrs, sleep for few mins and restart |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|