This script shows how to lock a file using a shell script and this can be useful to avoid multiple executions of the same script.
#!/bin/bash
set -e
(
/usr/bin/flock -n 200
# do stuff
) 200>fileToLock
With set -e execution ends if flock commands fails to lock the file.
No comments:
Post a Comment