Created
August 15, 2013 04:44
-
-
Save kteru/6238322 to your computer and use it in GitHub Desktop.
実行後 INTERVAL 秒待たないと再度実行できない仕組み
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
INTERVAL=10 | |
FILE_TMP="/tmp/tmpfile" | |
[ -f "${FILE_TMP}" ] || touch -t 197001010000 "${FILE_TMP}" | |
_prev=`stat -c '%Y' ${FILE_TMP}` | |
_now=`date '+%s'` | |
if [ $((_now - _prev)) -ge ${INTERVAL} ] | |
then | |
#------------------------------ | |
echo "executed" | |
#------------------------------ | |
touch "${FILE_TMP}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment