shell script to check availability of a file for 1 hour , after one hour if file not there , it will echo "Time Out"
i wrote this code. but the problem is after every 300s it prints "Time over", when $fname present is got out from the loop. I want "time over" after 1hr if file not arrived, but after 300s it starts to print "time over"
#!/bin/bash echo "enter file name" read fname START=`date +%s` while [ $(( $(date +%s) - 3600 )) -lt $START ]; do if [ -e $fname ] then echo "$fname present" break sleep 300 else echo "Time Over" fi done |
This basically does what you want
Code:
file=time.t |
would be nice to use code tags, otherwise hard to read and understand your script. This looks much better:
Code:
#!/bin/bash |
OMG. Thank you very much ...
|
If you really must have the echo in the loop, then a break must follow it:
Code:
#!/bin/bash it is better to query a variable after the loop: Code:
#!/bin/bash |
All times are GMT -5. The time now is 04:51 AM. |