条件失败后10分钟后自动运行Bash脚本

时间:2013-05-28 14:10:59

标签: bash

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

2 个答案:

答案 0 :(得分:2)

如果exexution失败,您可以使用at从脚本中重新安排脚本。在else块中,输入如下内容:

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

答案 1 :(得分: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
相关问题