Manage locks from shell scripts. It can be used to ensure that only one process of a command is running. More information: https://manned.org/flock.
flock path/to/lock.lock --command "command"
flock path/to/lock.lock --nonblock --command "command"
flock path/to/lock.lock --nonblock --conflict-exit-code error_code -c "command"