Skip to content

Instantly share code, notes, and snippets.

@kteru
Created August 15, 2013 04:44
Show Gist options
  • Save kteru/6238322 to your computer and use it in GitHub Desktop.
Save kteru/6238322 to your computer and use it in GitHub Desktop.
実行後 INTERVAL 秒待たないと再度実行できない仕組み
#!/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