While loop in certain interval


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting While loop in certain interval
# 1  
Old 10-15-2013
While loop in certain interval

Hi Gurus,

I have a script which loops a directory to find the file. right now, I want to add time interval which means every 15 minutes it checks the dir once. if all files are found, then exit with 0. if there are some files missing at 6:00am the process exit with 20. the script start at 7:00pm everyday by third part scheduler.
My current script like:
Code:
IFS=","
while read group file X
do   
   if [ -f $file ] ; then 
      time=$(ls -l $file |awk '{print $6,$7,$8}')
      echo "$group, $file, $time, YES"
   else 
      echo "$group, $file , NO"
   fi
done < list.txt

Thanks in advance.
# 2  
Old 10-15-2013
Use crontab

*/15 * * * * /path/to/command

cron - Wikipedia, the free encyclopedia
This User Gave Thanks to Akshay Hegde For This Post:
# 3  
Old 10-15-2013
Quote:
Originally Posted by Akshay Hegde
Use crontab

*/15 * * * * /path/to/command

cron - Wikipedia, the free encyclopedia
Thanks for your reply,

unfortunately, I can not use CRONTAB, I have to add this in my script.
# 4  
Old 10-15-2013
I think you can tell system to sleep for 900 seconds with infinite loop..might others will have better solution

---------- Post updated at 11:28 AM ---------- Previous update was at 11:23 AM ----------

something like this

Code:
$ while :; do sleep 1;echo "1 sec over start script again"; done

This User Gave Thanks to Akshay Hegde For This Post:
# 5  
Old 10-15-2013
Quote:
Originally Posted by Akshay Hegde
I think you can tell system to sleep for 900 seconds with infinite loop..might others will have better solution
Thanks for your reply.

This is I want, but I don't know how to implement this into my existing code. would you please give me a sample. (I need sleep 900 seconds and checking if the time is 6:00 AM or after 6:00AM, if yes, the script stops checking)
I tired below code: but I don't know how to check if the time is 6:00AM or later. would you please give me some help.
Code:
while :
do
time1=`date +"%d-%m-%Y:%T"`
echo "Start time: " $time1
sleep 60
time2=`date +"%d-%m-%Y:%T"`
echo "End time: " $time2
done

Thanks in advance
# 6  
Old 10-15-2013
try

Code:
while :
do 
   
IFS=","
while read group file X
do   
   if [ -f $file ] ; then 
      time=$(ls -l $file |awk '{print $6,$7,$8}')
      echo "$group, $file, $time, YES"
   else 
      echo "$group, $file , NO"
   fi
done < list.txt

    sleep 900
    echo " 900 sec over start script again"

done

This User Gave Thanks to Akshay Hegde For This Post:
# 7  
Old 10-15-2013
Quote:
Originally Posted by Akshay Hegde
try

Code:
while :
do 
   
IFS=","
while read group file X
do   
   if [ -f $file ] ; then 
      time=$(ls -l $file |awk '{print $6,$7,$8}')
      echo "$group, $file, $time, YES"
   else 
      echo "$group, $file , NO"
   fi
done < list.txt

    sleep 900
    echo " 900 sec over start script again"

done

Thanks for you quick reply.
I have one more question: how could I check if current time is 6:00AM over or not, because I need exits with error code after 6:00AM, if there are still some file missing.

Thanks in advance
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Repetition in a particular interval

Suppose I have a word which is repeating in a string continuously. I have a set of intervals. Then how do I find the number occurrences of that word in those intervals and their location of occurrences. For example - Suppose there is a huge string anfie.......sirn of 10000 letters. Now the word... (2 Replies)
Discussion started by: ANKIT ROY
2 Replies

2. Shell Programming and Scripting

Interval merging

I do have a file (file1) with a specified interval of 500 counts file1 0 500 500 1000 1000 1500 1500 2000 2000 2500 2500 3000 3000 3500 3500 4000 4000 4500 4500 5000 5000 5500 5500 6000 6000 6500 6500 7000 7000 7500 7500 8000 (3 Replies)
Discussion started by: Kanja
3 Replies

3. Shell Programming and Scripting

interval based count

Hi, I have a file with 4 million rows. what i am trying to achieve is for every 1000 interval count the number of rows and display it i/p 12 200 400 750 1000 1500 1800 2200 2345 2600 2896 3020 3400 (0 Replies)
Discussion started by: Diya123
0 Replies

4. Solaris

NTP polling interval

Is it possible to change the ntp poll manually. I notice that ntp poll is changing autimatically. (1 Reply)
Discussion started by: ningy
1 Replies

5. Shell Programming and Scripting

grep searching interval

Hi all, I just want to find all values that are in a specified interval. I tryed it with grep e- file , it does not work. Is it possible to get values wich are lower a special number, like grep >e-18 file? Thanks a lot (4 Replies)
Discussion started by: newcommer
4 Replies

6. Shell Programming and Scripting

compare the interval of 2 numbers of input2with interval of several numbers of input1

Help plz Does any one have any idea how to compare interval ranges of 2 files. finding 1-4 (1,2,3,4) of input2 in input1 of same key "a" values (5-10, 30-40, 45-60, 80-90, 100-120 ). Obviously 1-4 is not one of the range with in input1 a. so it should give out of range. finding 30-33(31,32,33)... (1 Reply)
Discussion started by: repinementer
1 Replies

7. UNIX for Advanced & Expert Users

Summation of the column value in an interval.

Hey, I have a file with following data.. and I want to get the summation of 10th column. And this happens in every 10 seconds for a minute max. 242001 A mqsitst 794864 1249516 0 60 20 293050400 77016 * 02:05:33 - 0:04 DataFlowEngine EAITIBR2_BROKER... (6 Replies)
Discussion started by: varungupta
6 Replies

8. OS X (Apple)

interval in a launchd script

Hi, i'm planning a to automate my backup with a rsync user deamon in my launchd and let that run every 2 hours. my server contains a lot of video data which can expand rapidly , up to 1TB, in an interval of 2 hours. now i'm wondering what will happen when a rsync is running longer then the... (1 Reply)
Discussion started by: wessel
1 Replies

9. Shell Programming and Scripting

Need Help for interval date

Hello, I need help about a shell script I have a text file with this fields: 2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error. 2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error. 2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an... (4 Replies)
Discussion started by: giofai
4 Replies

10. Solaris

Time Wait interval

What is the time_wait interval for Solaris 8/9??? and is it configurable??? For example sometimes a clients pc will freeze up dropping the connection, closing the port. The problem is on our side our system still thinks their logged in (until it realizes it dropped on the otherside and drops on... (1 Reply)
Discussion started by: eloquent99
1 Replies
Login or Register to Ask a Question