bash locking in script
Bash locking Intro Once in a while i want to start a bash script and make sure it one at a time. So searching for solution for creating a lock file in bash, you want to have a solution that doesn’t create a race condition.
Explanation Start defining which lockfile you want to use
export lockfile=/tmp/lockfile.txt
Get pid from lockfile, return empty string if file doesn’t exists or is empty For added protection removed character from the file that isn’t a number
3 minutes to read