Using flock
from the util-linux package.
37 * * * * /usr/bin/flock -n /some/file -c do-something-important-with /some/file
Using the programs from the lockfile-progs package.
lockfile-create /some/file
lockfile-touch /some/file &
# Save the PID of the lockfile-touch process
BADGER="$!"
do-something-important-with /some/file
kill "${BADGER}"
lockfile-remove /some/file