2013-05-28 145 views
0
if [ $FILE_SIZE -ge 5000000000 and $FILE_SIZE -le 10000000000 ] 

then 

cp $s/* $W 

else 

#Here I need to wait the script for 10 minutes and re-run the if condition again 

echo "file $myfile is out of Limit" 

fi 
+0

在while(condition)中寫入sleep 10分鐘 – Kent

回答

1

你可以使用sleep等待10分鐘,像這樣:

while true ; do 
    if [ "$FILE_SIZE" -ge 5000000000 -a "$FILE_SIZE" -le 10000000000 ] ; then ; break ; fi 
    echo "file $myfile is out of Limit" 
    sleep 600 
done 

cp $s/* $W 
2

您可以使用at從腳本內重新安排腳本如果執行失敗。在else塊中,加入如下內容:

at now + 10 minutes << END 
./$0 
END