Skip to content

Instantly share code, notes, and snippets.

@pahud
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pahud/9825419 to your computer and use it in GitHub Desktop.
Save pahud/9825419 to your computer and use it in GitHub Desktop.
execute cron job with flock
MAILTO='your@gmail.com'
# my cronjob
MP_UPD_LOCK='/tmp/.your_lock_file.lock'
* * * * * pahud /usr/bin/flock -w1 ${MP_UPD_LOCK} /usr/bin/python -c "from xxxx import foo as f; f.FooBar().update()" > /dev/null || SUBJ="[ERROR] flock on ${MP_UPD_LOCK} failed"; mail -s "${SUBJ}" "${MAILTO}" > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment