This task is to determine if there is only one instance of an application running. If the program discovers that an instance of it is already running, then it should display a message indicating that it is already running and exit.

 
local fd=${2:-200}
 
# create lock file
eval "exec $fd>/tmp/my_lock.lock"
 
# acquire the lock, or fail 
flock -nx $fd \
&& # do something if you got the lock \
|| # do something if you did not get the lock
 