#!/usr/local/bin/bash if [ -e /tmp/$1.lock ]; then echo "Could not execute $1 due to lockfile..." | mail -s "LOCKFILE: your.domain.tld - error running $1" runlock@domain.tld exit 1; fi touch /tmp/$1.lock $2 rm /tmp/$1.lock