Skip to content

Instantly share code, notes, and snippets.

@pahud
Last active Aug 29, 2015
Embed
What would you like to do?
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